use of io.atlasmap.expression.ExpressionContext in project atlasmap by atlasmap.
the class ISEMPTY method create.
@Override
public Expression create(List<Expression> args) throws ParseException {
if (args.size() != 1) {
throw new ParseException("ISEMPTY expects 1 argument.");
}
final Expression arg = args.get(0);
return new BooleanExpression() {
public Field evaluate(ExpressionContext ctx) throws ExpressionException {
Field f = arg.evaluate(ctx);
Object value = f == null ? null : f.getValue();
if (value == null || value.toString().isEmpty()) {
return wrapWithField(Boolean.TRUE);
}
return wrapWithField(Boolean.FALSE);
}
public boolean matches(ExpressionContext ctx) throws ExpressionException {
Object answer = evaluate(ctx).getValue();
return answer != null && answer == Boolean.TRUE;
}
};
}
Aggregations