use of org.kie.dmn.feel.runtime.Range in project drools by kiegroup.
the class TypeUtil method formatValue.
public static String formatValue(final Object val, final boolean wrapForCodeUsage) {
if (val instanceof String) {
return formatString(val.toString(), wrapForCodeUsage);
} else if (val instanceof LocalDate) {
return formatDate((LocalDate) val, wrapForCodeUsage);
} else if (val instanceof LocalTime || val instanceof OffsetTime) {
return formatTimeString(TimeFunction.FEEL_TIME.format((TemporalAccessor) val), wrapForCodeUsage);
} else if (val instanceof LocalDateTime || val instanceof OffsetDateTime) {
return formatDateTimeString(DateAndTimeFunction.FEEL_DATE_TIME.format((TemporalAccessor) val), wrapForCodeUsage);
} else if (val instanceof ZonedDateTime) {
TemporalAccessor ta = (TemporalAccessor) val;
ZoneId zone = ta.query(TemporalQueries.zone());
if (!(zone instanceof ZoneOffset)) {
// it is a ZoneRegion
return formatDateTimeString(DateAndTimeFunction.REGION_DATETIME_FORMATTER.format((TemporalAccessor) val), wrapForCodeUsage);
} else {
return formatDateTimeString(DateAndTimeFunction.FEEL_DATE_TIME.format((TemporalAccessor) val), wrapForCodeUsage);
}
} else if (val instanceof Duration) {
return formatDuration((Duration) val, wrapForCodeUsage);
} else if (val instanceof ChronoPeriod) {
return formatPeriod((ChronoPeriod) val, wrapForCodeUsage);
} else if (val instanceof TemporalAccessor) {
TemporalAccessor ta = (TemporalAccessor) val;
if (ta.query(TemporalQueries.localDate()) == null && ta.query(TemporalQueries.localTime()) != null && ta.query(TemporalQueries.zoneId()) != null) {
return formatTimeString(TimeFunction.FEEL_TIME.format((TemporalAccessor) val), wrapForCodeUsage);
} else {
return String.valueOf(val);
}
} else if (val instanceof List) {
return formatList((List) val, wrapForCodeUsage);
} else if (val instanceof Range) {
return formatRange((Range) val, wrapForCodeUsage);
} else if (val instanceof Map) {
return formatContext((Map) val, wrapForCodeUsage);
} else {
return String.valueOf(val);
}
}
use of org.kie.dmn.feel.runtime.Range in project drools by kiegroup.
the class DuringFunctionTest method invokeParamIsNull.
@Test
public void invokeParamIsNull() {
FunctionTestUtil.assertResultError(duringFunction.invoke((Comparable) null, (Range) new RangeImpl()), InvalidParametersEvent.class);
FunctionTestUtil.assertResultError(duringFunction.invoke((Comparable) "a", (Range) null), InvalidParametersEvent.class);
}
use of org.kie.dmn.feel.runtime.Range in project drools by kiegroup.
the class FinishedByFunctionTest method invokeParamIsNull.
@Test
public void invokeParamIsNull() {
FunctionTestUtil.assertResultError(finishedByFunction.invoke((Range) null, (Comparable) "b"), InvalidParametersEvent.class);
FunctionTestUtil.assertResultError(finishedByFunction.invoke((Range) new RangeImpl(), (Comparable) null), InvalidParametersEvent.class);
}
use of org.kie.dmn.feel.runtime.Range in project drools by kiegroup.
the class MeetsFunctionTest method invokeParamIsNull.
@Test
public void invokeParamIsNull() {
FunctionTestUtil.assertResultError(meetsFunction.invoke((Range) null, (Range) new RangeImpl()), InvalidParametersEvent.class);
FunctionTestUtil.assertResultError(meetsFunction.invoke((Range) new RangeImpl(), (Range) null), InvalidParametersEvent.class);
}
use of org.kie.dmn.feel.runtime.Range in project drools by kiegroup.
the class FinishesFunctionTest method invokeParamIsNull.
@Test
public void invokeParamIsNull() {
FunctionTestUtil.assertResultError(finishesFunction.invoke((Comparable) null, (Range) new RangeImpl()), InvalidParametersEvent.class);
FunctionTestUtil.assertResultError(finishesFunction.invoke((Comparable) "a", (Range) null), InvalidParametersEvent.class);
}
Aggregations