@Test public void testEvaluate() { Function f = FF.function("mapGet", FF.property("attributes"), FF.literal("name")); assertEquals("firstObject", f.evaluate(features[0], String.class)); assertEquals("secondObject", f.evaluate(features[1], String.class)); assertEquals("thirdObject", f.evaluate(features[2], String.class)); PropertyIsGreaterThan gt = FF.greater( FF.function("mapGet", FF.property("attributes"), FF.literal("score")), FF.literal(80)); assertEquals(true, gt.evaluate(features[0])); assertEquals(false, gt.evaluate(features[1])); assertEquals(false, gt.evaluate(features[2])); Function f2 = FF.function("mapGet", FF.property("attributes"), FF.literal("valid")); assertFalse(f2.evaluate(features[0], Boolean.class)); assertTrue(f2.evaluate(features[1], Boolean.class)); assertNull(f2.evaluate(features[2], Boolean.class)); Function f3 = FF.function("mapGet", FF.property("attributes"), FF.literal("key1")); assertEquals("value1", f3.evaluate(features[0], String.class)); assertEquals(Integer.valueOf(10), f3.evaluate(features[1], Integer.class)); assertEquals(Boolean.TRUE, f3.evaluate(features[2], Boolean.class)); Function f4 = FF.function("mapGet", FF.property("missingMap"), FF.literal("key1")); assertNull(f4.evaluate(features[0], String.class)); }
@Override public Object evaluate(Object object, Class context) { Object result = evaluate(object); if (result == null) { return null; } else { return Converters.convert(result, context); } }
MapGetFunction extends FunctionExpressionImpl implements VolatileFunction { @Override public Object evaluate(Object object, Class context) { Object result = evaluate(object); if (result == null) { return null; } else { return Converters.convert(result, context); } } }
MapGetFunction extends FunctionExpressionImpl implements VolatileFunction { @Override public Object evaluate(Object object, Class context) { Object result = evaluate(object); if (result == null) { return null; } else { return Converters.convert(result, context); } } MapGetFunction(); }
MapGetFunction extends FunctionExpressionImpl implements VolatileFunction { @Override public Object evaluate(Object object, Class context) { Object result = evaluate(object); if (result == null) { return null; } else { return Converters.convert(result, context); } } MapGetFunction(); @Override Object evaluate(Object object, Class context); Object evaluate(Object feature); }
MapGetFunction extends FunctionExpressionImpl implements VolatileFunction { @Override public Object evaluate(Object object, Class context) { Object result = evaluate(object); if (result == null) { return null; } else { return Converters.convert(result, context); } } MapGetFunction(); @Override Object evaluate(Object object, Class context); Object evaluate(Object feature); static FunctionName NAME; }