use of org.kie.dmn.feel.runtime.impl.RangeImpl in project drools by kiegroup.
the class RangeNode method evaluate.
@Override
public Range evaluate(EvaluationContext ctx) {
Object s = start.evaluate(ctx);
Object e = end.evaluate(ctx);
Type sType = BuiltInType.determineTypeFromInstance(s);
Type eType = BuiltInType.determineTypeFromInstance(e);
if (s != null && e != null && sType != eType && !s.getClass().isAssignableFrom(e.getClass())) {
ctx.notifyEvt(astEvent(Severity.ERROR, Msg.createMessage(Msg.X_TYPE_INCOMPATIBLE_WITH_Y_TYPE, "Start", "End")));
return null;
}
Comparable start = convertToComparable(ctx, s);
Comparable end = convertToComparable(ctx, e);
return new RangeImpl(lowerBound == IntervalBoundary.OPEN ? Range.RangeBoundary.OPEN : Range.RangeBoundary.CLOSED, start, end, upperBound == IntervalBoundary.OPEN ? Range.RangeBoundary.OPEN : Range.RangeBoundary.CLOSED);
}
use of org.kie.dmn.feel.runtime.impl.RangeImpl in project drools by kiegroup.
the class FEELSchemaEnumTest method testBasic.
@Test
public void testBasic() {
List<Range> list = new ArrayList<>();
list.add(new RangeImpl(RangeBoundary.CLOSED, 0, null, RangeBoundary.CLOSED));
list.add(new RangeImpl(RangeBoundary.CLOSED, null, 100, RangeBoundary.CLOSED));
Range result = FEELSchemaEnum.consolidateRanges(list);
Assertions.assertThat(result).isNotNull().isEqualTo(new RangeImpl(RangeBoundary.CLOSED, 0, 100, RangeBoundary.CLOSED));
}
Aggregations