@Test void differentStringsDoNotSubsumeEachOther() { final FeelExpression stringExpression = FeelParser.PARSER.parse("\"somestring\""); final FeelExpression otherStringExpression = FeelParser.PARSER.parse("\"otherstring\""); assertEquals(Optional.of(false), Subsumption.subsumes(stringExpression, otherStringExpression, Subsumption.eq)); }
static Optional<Boolean> subsumes(final FeelExpression expression, final FeelExpression otherExpression, final Comparison comparison) { return FeelExpressions.caseOf(expression) .Empty_(Optional.of(true)) .Null_(FeelExpressions.caseOf(otherExpression).Null_(Optional.of(true)).otherwise_(Optional.of(false))) .BooleanLiteral((aBool) -> compareLiterals(aBool, FeelExpressions::getABoolean, otherExpression, comparison)) .DateLiteral((dateTime) -> compareLiterals(dateTime, FeelExpressions::getDateTime, otherExpression, comparison)) .DoubleLiteral((aDouble) -> compareLiterals(aDouble, FeelExpressions::getADouble, otherExpression, comparison)) .IntegerLiteral((integer) -> compareLiterals(integer, FeelExpressions::getAInteger, otherExpression, comparison)) .StringLiteral((string) -> compareLiterals(string, FeelExpressions::getString, otherExpression, eq)) .VariableLiteral((name) -> subsumesVariableLiteral(name, otherExpression, comparison)) .RangeExpression((leftInc, lowerBound, upperBound, rightInc) -> subsumesRangeExpression(leftInc, lowerBound, upperBound, rightInc, otherExpression)) .UnaryExpression((operator, operand) -> subsumesUnaryExpression(operator, operand, otherExpression)) .otherwise_(Optional.empty()); }
Subsumption { static Optional<Boolean> subsumes(final FeelExpression expression, final FeelExpression otherExpression, final Comparison comparison) { return FeelExpressions.caseOf(expression) .Empty_(Optional.of(true)) .Null_(FeelExpressions.caseOf(otherExpression).Null_(Optional.of(true)).otherwise_(Optional.of(false))) .BooleanLiteral((aBool) -> compareLiterals(aBool, FeelExpressions::getABoolean, otherExpression, comparison)) .DateLiteral((dateTime) -> compareLiterals(dateTime, FeelExpressions::getDateTime, otherExpression, comparison)) .DoubleLiteral((aDouble) -> compareLiterals(aDouble, FeelExpressions::getADouble, otherExpression, comparison)) .IntegerLiteral((integer) -> compareLiterals(integer, FeelExpressions::getAInteger, otherExpression, comparison)) .StringLiteral((string) -> compareLiterals(string, FeelExpressions::getString, otherExpression, eq)) .VariableLiteral((name) -> subsumesVariableLiteral(name, otherExpression, comparison)) .RangeExpression((leftInc, lowerBound, upperBound, rightInc) -> subsumesRangeExpression(leftInc, lowerBound, upperBound, rightInc, otherExpression)) .UnaryExpression((operator, operand) -> subsumesUnaryExpression(operator, operand, otherExpression)) .otherwise_(Optional.empty()); } }
Subsumption { static Optional<Boolean> subsumes(final FeelExpression expression, final FeelExpression otherExpression, final Comparison comparison) { return FeelExpressions.caseOf(expression) .Empty_(Optional.of(true)) .Null_(FeelExpressions.caseOf(otherExpression).Null_(Optional.of(true)).otherwise_(Optional.of(false))) .BooleanLiteral((aBool) -> compareLiterals(aBool, FeelExpressions::getABoolean, otherExpression, comparison)) .DateLiteral((dateTime) -> compareLiterals(dateTime, FeelExpressions::getDateTime, otherExpression, comparison)) .DoubleLiteral((aDouble) -> compareLiterals(aDouble, FeelExpressions::getADouble, otherExpression, comparison)) .IntegerLiteral((integer) -> compareLiterals(integer, FeelExpressions::getAInteger, otherExpression, comparison)) .StringLiteral((string) -> compareLiterals(string, FeelExpressions::getString, otherExpression, eq)) .VariableLiteral((name) -> subsumesVariableLiteral(name, otherExpression, comparison)) .RangeExpression((leftInc, lowerBound, upperBound, rightInc) -> subsumesRangeExpression(leftInc, lowerBound, upperBound, rightInc, otherExpression)) .UnaryExpression((operator, operand) -> subsumesUnaryExpression(operator, operand, otherExpression)) .otherwise_(Optional.empty()); }  }
Subsumption { static Optional<Boolean> subsumes(final FeelExpression expression, final FeelExpression otherExpression, final Comparison comparison) { return FeelExpressions.caseOf(expression) .Empty_(Optional.of(true)) .Null_(FeelExpressions.caseOf(otherExpression).Null_(Optional.of(true)).otherwise_(Optional.of(false))) .BooleanLiteral((aBool) -> compareLiterals(aBool, FeelExpressions::getABoolean, otherExpression, comparison)) .DateLiteral((dateTime) -> compareLiterals(dateTime, FeelExpressions::getDateTime, otherExpression, comparison)) .DoubleLiteral((aDouble) -> compareLiterals(aDouble, FeelExpressions::getADouble, otherExpression, comparison)) .IntegerLiteral((integer) -> compareLiterals(integer, FeelExpressions::getAInteger, otherExpression, comparison)) .StringLiteral((string) -> compareLiterals(string, FeelExpressions::getString, otherExpression, eq)) .VariableLiteral((name) -> subsumesVariableLiteral(name, otherExpression, comparison)) .RangeExpression((leftInc, lowerBound, upperBound, rightInc) -> subsumesRangeExpression(leftInc, lowerBound, upperBound, rightInc, otherExpression)) .UnaryExpression((operator, operand) -> subsumesUnaryExpression(operator, operand, otherExpression)) .otherwise_(Optional.empty()); }   }
Subsumption { static Optional<Boolean> subsumes(final FeelExpression expression, final FeelExpression otherExpression, final Comparison comparison) { return FeelExpressions.caseOf(expression) .Empty_(Optional.of(true)) .Null_(FeelExpressions.caseOf(otherExpression).Null_(Optional.of(true)).otherwise_(Optional.of(false))) .BooleanLiteral((aBool) -> compareLiterals(aBool, FeelExpressions::getABoolean, otherExpression, comparison)) .DateLiteral((dateTime) -> compareLiterals(dateTime, FeelExpressions::getDateTime, otherExpression, comparison)) .DoubleLiteral((aDouble) -> compareLiterals(aDouble, FeelExpressions::getADouble, otherExpression, comparison)) .IntegerLiteral((integer) -> compareLiterals(integer, FeelExpressions::getAInteger, otherExpression, comparison)) .StringLiteral((string) -> compareLiterals(string, FeelExpressions::getString, otherExpression, eq)) .VariableLiteral((name) -> subsumesVariableLiteral(name, otherExpression, comparison)) .RangeExpression((leftInc, lowerBound, upperBound, rightInc) -> subsumesRangeExpression(leftInc, lowerBound, upperBound, rightInc, otherExpression)) .UnaryExpression((operator, operand) -> subsumesUnaryExpression(operator, operand, otherExpression)) .otherwise_(Optional.empty()); }    }