@Test public void testLiteralDefaultValue() { System.out.println(" literal default value"); int defaultValue = 42; Object result = ff.function("env", ff.literal("doesnotexist"), ff.literal(defaultValue)).evaluate(null); int value = ((Number) result).intValue(); assertEquals(defaultValue, value); }
@Override public Object evaluate(Object feature) { String varName = getExpression(0).evaluate(feature, String.class); Object value = localLookup.getTable().get(varName.toUpperCase()); if (value == null) { value = globalLookup.get(varName.toUpperCase()); } if (value == null) { final int paramSize = getParameters().size(); if (paramSize > getArgCount()) { value = getExpression(paramSize - 1).evaluate(feature); } } return value; }
EnvFunction extends FunctionExpressionImpl { @Override public Object evaluate(Object feature) { String varName = getExpression(0).evaluate(feature, String.class); Object value = localLookup.getTable().get(varName.toUpperCase()); if (value == null) { value = globalLookup.get(varName.toUpperCase()); } if (value == null) { final int paramSize = getParameters().size(); if (paramSize > getArgCount()) { value = getExpression(paramSize - 1).evaluate(feature); } } return value; } }
EnvFunction extends FunctionExpressionImpl { @Override public Object evaluate(Object feature) { String varName = getExpression(0).evaluate(feature, String.class); Object value = localLookup.getTable().get(varName.toUpperCase()); if (value == null) { value = globalLookup.get(varName.toUpperCase()); } if (value == null) { final int paramSize = getParameters().size(); if (paramSize > getArgCount()) { value = getExpression(paramSize - 1).evaluate(feature); } } return value; } EnvFunction(); }
EnvFunction extends FunctionExpressionImpl { @Override public Object evaluate(Object feature) { String varName = getExpression(0).evaluate(feature, String.class); Object value = localLookup.getTable().get(varName.toUpperCase()); if (value == null) { value = globalLookup.get(varName.toUpperCase()); } if (value == null) { final int paramSize = getParameters().size(); if (paramSize > getArgCount()) { value = getExpression(paramSize - 1).evaluate(feature); } } return value; } EnvFunction(); static void setLocalValues(Map<String, Object> values); static void clearLocalValues(); static void setGlobalValues(Map<String, Object> values); static void clearGlobalValues(); static void setLocalValue(String name, Object value); static void setGlobalValue(String name, Object value); @Override int getArgCount(); @Override Object evaluate(Object feature); @Override void setParameters(List params); @Override void setFallbackValue(Literal fallback); }
EnvFunction extends FunctionExpressionImpl { @Override public Object evaluate(Object feature) { String varName = getExpression(0).evaluate(feature, String.class); Object value = localLookup.getTable().get(varName.toUpperCase()); if (value == null) { value = globalLookup.get(varName.toUpperCase()); } if (value == null) { final int paramSize = getParameters().size(); if (paramSize > getArgCount()) { value = getExpression(paramSize - 1).evaluate(feature); } } return value; } EnvFunction(); static void setLocalValues(Map<String, Object> values); static void clearLocalValues(); static void setGlobalValues(Map<String, Object> values); static void clearGlobalValues(); static void setLocalValue(String name, Object value); static void setGlobalValue(String name, Object value); @Override int getArgCount(); @Override Object evaluate(Object feature); @Override void setParameters(List params); @Override void setFallbackValue(Literal fallback); static FunctionName NAME; }