public UnaryTestNode( String op, BaseNode value ) { super(); setText( op+" "+value.getText() ); this.operator = UnaryOperator.determineOperator( op ); this.value = value; }
public UnaryTestListNode(ParserRuleContext ctx, List<BaseNode> elements, State state) { super(ctx); this.elements = elements; this.state = state; if (isNegated()) { notNode = ASTBuilderFactory.newUnaryTestNode(ctx, "not", ASTBuilderFactory.newListNode(ctx, elements)); } }
public BaseNode rewriteToUnaryEqInExpr(BaseNode node) { if (node instanceof ListNode || node instanceof RangeNode) { return ASTBuilderFactory.newUnaryTestNode( node.getParserRuleContext(), "in", node); } else { return ASTBuilderFactory.newUnaryTestNode( node.getParserRuleContext(), "=", node); } }
private Object fetchValue(Object o) throws IllegalAccessException, InvocationTargetException { if ( name instanceof NameRefNode ) { o = EvalHelper.getValue( o, name.getText() ); } else if ( name instanceof QualifiedNameNode ) { for ( NameRefNode nr : ((QualifiedNameNode) name).getParts() ) { o = EvalHelper.getValue( o, nr.getText() ); } } return o; }
@Override public Type getResultType() { return findType(expression.getResultType(), name); }
private UnaryTest createIsEqualUnaryTest( ) { return (context, left) -> { Object right = value.evaluate( context ); return utEqualSemantic(left, right, context); }; }
public static boolean nextIteration(EvaluationContext ctx, QEIteration[] ictx) { int i = ictx.length-1; while ( i >= 0 && i < ictx.length ) { if ( ictx[i].hasNextValue() ) { setValueIntoContext( ctx, ictx[i] ); i++; } else { i--; } } return i >= 0; }
public static boolean nextIteration(EvaluationContext ctx, ForIteration[] ictx) { int i = ictx.length-1; while ( i >= 0 && i < ictx.length ) { if ( ictx[i].hasNextValue() ) { setValueIntoContext( ctx, ictx[i] ); i++; } else { i--; } } return i >= 0; }
@Override public <T> T accept(Visitor<T> v) { return v.visit(this); } }
public NameRefNode(ParserRuleContext ctx, String text, Type type) { super( ctx ); this.resultType = type; this.setText(text); }
/** * FEEL spec Table 38 * Delegates to {@link InfixOpNode} except evaluationcontext */ public static Object and(Object left, Object right) { return InfixOpNode.and(left, right, null); }
/** * FEEL spec Table 38 * Delegates to {@link InfixOpNode} except evaluationcontext */ public static Object or(Object left, Object right) { return InfixOpNode.or(left, right, null); }
/** * FEEL spec Table 45 * Delegates to {@link InfixOpNode} except evaluationcontext */ public static Object sub(Object left, Object right) { return InfixOpNode.sub(left, right, null); }
/** * FEEL spec Table 45 * Delegates to {@link InfixOpNode} except evaluationcontext */ public static Object mult(Object left, Object right) { return InfixOpNode.mult(left, right, null); }
@Override public Object evaluate(EvaluationContext ctx) { // spec says: if FEEL(e1) is true then FEEL(e2) else FEEL(e3) Object cond = this.condition.evaluate( ctx ); if ( cond != null && cond instanceof Boolean && cond == Boolean.TRUE ) { return this.thenExpression.evaluate( ctx ); } else { return this.elseExpression.evaluate( ctx ); } }
private BaseNode rewriteToUnaryTestExpr(BaseNode node) { return ASTBuilderFactory.newUnaryTestNode( node.getParserRuleContext(), "test", node); }
private UnaryTest createIsNotEqualUnaryTest( ) { return (context, left) -> { Object right = value.evaluate( context ); Boolean result = utEqualSemantic(left, right, context); return result != null ? ! result : null; }; }
@Override public <T> T accept(Visitor<T> v) { return v.visit(this); } }
@Override public <T> T accept(Visitor<T> v) { return v.visit(this); } }