use of org.kie.dmn.feel.lang.types.impl.ImmutableFPAWrappingPOJO in project drools by kiegroup.
the class ContextPutFunction method toMap.
public static FEELFnResult<Map<String, Object>> toMap(Object context) {
Map<String, Object> result;
if (context instanceof Map) {
result = new HashMap<>();
Map<?, ?> contextMap = (Map<?, ?>) context;
for (Entry<?, ?> kv : contextMap.entrySet()) {
if (kv.getKey() instanceof String) {
result.put((String) kv.getKey(), kv.getValue());
} else {
FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "found a key which is not a string: " + kv.getKey()));
}
}
} else if (BuiltInType.determineTypeFromInstance(context) == BuiltInType.UNKNOWN) {
result = new ImmutableFPAWrappingPOJO(context).allFEELProperties();
} else {
return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "context", "is not a context"));
}
return FEELFnResult.ofResult(result);
}
Aggregations