/** * Gets an input-output map. * @param message the message * @param operation the operation * @param runtime the runtime engine * @return the input-output map */ public static Map<String, Object> getInputOutputMap(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { Map<String, Object> map = new LinkedHashMap<String, Object>(); Map<String, ExpressionMapping> inputs = operation.getInputOutputExpressionMappings(); for (Entry<String, ExpressionMapping> entry : inputs.entrySet()) { List<Object> list = getList(message, Collections.singletonList(entry.getValue())); final Object output; switch (list.size()) { case 0: output = null; break; case 1: output = list.get(0); break; default: output = list; } map.put(entry.getKey(), output); } return map; }
/** * Gets an input-output map. * @param message the message * @param operation the operation * @param runtime the runtime engine * @return the input-output map */ public static Map<String, Object> getInputOutputMap(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { Map<String, Object> map = new LinkedHashMap<String, Object>(); Map<String, ExpressionMapping> inputs = operation.getInputOutputExpressionMappings(); for (Entry<String, ExpressionMapping> entry : inputs.entrySet()) { List<Object> list = getList(message, Collections.singletonList(entry.getValue())); final Object output; switch (list.size()) { case 0: output = null; break; case 1: output = list.get(0); break; default: output = list; } map.put(entry.getKey(), output); } return map; }