private Expression wrapBooleanOperationLeft(Expression exp, Operator operator) { switch (operator) { case AND: case AND2: case OR: case OR2: case TERNARY: if (exp != null) return new AsBooleanExpression(exp); } return exp; }
private Expression wrapBooleanOperationRight(Expression exp, Operator operator) { switch (operator) { case AND: case AND2: case OR: case OR2: case NOT: if (exp != null) return new AsBooleanExpression(exp); } return exp; }
private Expression wrapBooleanOperationRight(Expression exp, Operator operator) { switch (operator) { case AND: case AND2: case OR: case OR2: case NOT: if (exp != null) return new AsBooleanExpression(exp); } return exp; }
private Expression wrapBooleanOperationLeft(Expression exp, Operator operator) { switch (operator) { case AND: case AND2: case OR: case OR2: case TERNARY: if (exp != null) return new AsBooleanExpression(exp); } return exp; }
@Override public Expression clone() { return new AsBooleanExpression(condition.clone()); }
@Override public Expression clone() { return new AsBooleanExpression(condition.clone()); }
public Expression prepare(Map<String, Object> model, Map<String, UserFunction> functions, List<String> imports) { switch (type) { case IF: { List<String> args = getBlocks(statement, true); if (args.size() > 1) throw new IllegalStateException("more then one statement in condition: " + statement); AsBooleanExpression condition = new AsBooleanExpression(EvalTools.prepare(args.get(0), model, functions, imports)); Expression then = bodyStatement != null ? bodyStatement.prepare(model, functions, imports) : EvalTools.prepare(body, model, functions, imports); Expression elseExpression = optionalStatement != null ? optionalStatement.prepare(model, functions, imports) : EvalTools.prepare(optional, model, functions, imports); if (elseExpression == null) return new IfExpression(condition, then); else return new IfExpression(condition, then, elseExpression); } default: throw new IllegalStateException("not implemented yet"); } }
public Expression prepare(Map<String, Object> model, Map<String, UserFunction> functions, List<String> imports) { switch (type) { case IF: { List<String> args = getBlocks(statement, true); if (args.size() > 1) throw new IllegalStateException("more then one statement in condition: " + statement); AsBooleanExpression condition = new AsBooleanExpression(EvalTools.prepare(args.get(0), model, functions, imports)); Expression then = bodyStatement != null ? bodyStatement.prepare(model, functions, imports) : EvalTools.prepare(body, model, functions, imports); Expression elseExpression = optionalStatement != null ? optionalStatement.prepare(model, functions, imports) : EvalTools.prepare(optional, model, functions, imports); if (elseExpression == null) return new IfExpression(condition, then); else return new IfExpression(condition, then, elseExpression); } default: throw new IllegalStateException("not implemented yet"); } }