TypeOfFunction implements Function<Boolean> { @Override public Boolean apply(List<Object> objects) { Object value = objects.get(0); Object desiredDataType = objects.get(1); DataType dataType = getDataType(desiredDataType).get(); switch (dataType) { case STRING: return value instanceof String; case INTEGER: return value != null && Integer.class.isAssignableFrom(value.getClass()); case FLOAT: return value != null && Double.class.isAssignableFrom(value.getClass()); case NULL: return value == null || value instanceof Null; } return false; }  @Override Set<String> validateInput(List<Object> args); @Override Class<Boolean> getReturnType(); @Override FunctionName getName(); @Override Boolean apply(List<Object> objects); @Override String getSignature(); @Override String getDescription();  }
@Test public void testApply() throws Exception { assertThat(function.apply(Arrays.asList(1, INTEGER)), is(true)); assertThat(function.apply(Arrays.asList("str", STRING)), is(true)); assertThat(function.apply(Arrays.asList(5d, FLOAT)), is(true)); assertThat(function.apply(Arrays.asList(new Null(), NULL)), is(true)); assertThat(function.apply(Arrays.asList(null, NULL)), is(true)); assertThat(function.apply(Arrays.asList("test", INTEGER)), is(false)); }