/** * FEEL spec Table 42 and derivations * Delegates to {@link EvalHelper} except evaluationcontext */ public static Boolean gte(Object left, Object right) { return EvalHelper.compare(left, right, null, (l, r) -> l.compareTo(r) >= 0); }
/** * FEEL spec Table 42 and derivations * Delegates to {@link EvalHelper} except evaluationcontext */ public static Boolean lte(Object left, Object right) { return EvalHelper.compare(left, right, null, (l, r) -> l.compareTo(r) <= 0); }
/** * FEEL spec Table 42 and derivations * Delegates to {@link EvalHelper} except evaluationcontext */ public static Boolean lt(Object left, Object right) { return EvalHelper.compare(left, right, null, (l, r) -> l.compareTo(r) < 0); }
/** * FEEL spec Table 42 and derivations * Delegates to {@link EvalHelper} except evaluationcontext */ public static Boolean gt(Object left, Object right) { return EvalHelper.compare(left, right, null, (l, r) -> l.compareTo(r) > 0); }
private UnaryTest createCompareUnaryTest( BiPredicate<Comparable, Comparable> op ) { return (context, left) -> { Object right = value.evaluate( context ); return EvalHelper.compare( left, right, context, op ); }; }
/** * Compares left and right for equality applying FEEL semantics to specific data types * * @param left * @param right * @param ctx * @return */ public static Boolean isEqual(Object left, Object right, EvaluationContext ctx ) { if ( left == null || right == null ) { return left == right; } // spec defines that "a=[a]", i.e., singleton collections should be treated as the single element // and vice-versa if( left instanceof Collection && !(right instanceof Collection) && ((Collection)left).size() == 1 ) { left = ((Collection)left).toArray()[0]; } else if( right instanceof Collection && !(left instanceof Collection) && ((Collection)right).size()==1 ) { right = ((Collection) right).toArray()[0]; } if( left instanceof Range && right instanceof Range ) { return isEqual( (Range)left, (Range) right ); } else if( left instanceof Iterable && right instanceof Iterable ) { return isEqual( (Iterable)left, (Iterable) right ); } else if( left instanceof Map && right instanceof Map ) { return isEqual( (Map)left, (Map) right ); } return compare( left, right, ctx, (l, r) -> l.compareTo( r ) == 0 ); }
return or( left, right, ctx ); case LTE: return EvalHelper.compare( left, right, ctx, (l, r) -> l.compareTo( r ) <= 0 ); case LT: return EvalHelper.compare( left, right, ctx, (l, r) -> l.compareTo( r ) < 0 ); case GT: return EvalHelper.compare( left, right, ctx, (l, r) -> l.compareTo( r ) > 0 ); case GTE: return EvalHelper.compare( left, right, ctx, (l, r) -> l.compareTo( r ) >= 0 ); case EQ: return EvalHelper.isEqual( left, right, ctx );