aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java b/src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java
index 0278508..3437735 100644
--- a/src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java
+++ b/src/main/java/org/openecomp/sdc/toscaparser/api/functions/Function.java
@@ -98,31 +98,40 @@ public abstract class Function {
if (rawFunctionObj instanceof LinkedHashMap) { // In map type case
LinkedHashMap rawFunction = ((LinkedHashMap) rawFunctionObj);
- if(rawFunction.size() == 1) { // End point
+ if(rawFunction.size() == 1 &&
+ !(rawFunction.values().iterator().next() instanceof LinkedHashMap)) { // End point
return getFunctionForObjectItem(ttpl, context, rawFunction, resolveGetInput);
} else {
- // iterate over map nested properties in recursion, convert leaves to function,
- // and collect them in the same hierarchy as the original map.
- LinkedHashMap rawFunctionObjMap = new LinkedHashMap();
- for (Object rawFunctionObjItem: rawFunction.entrySet()) {
- Object itemValue = getFunction(ttpl, context, ((Map.Entry)rawFunctionObjItem).getValue(), resolveGetInput);
- rawFunctionObjMap.put(((Map.Entry)rawFunctionObjItem).getKey(), itemValue);
- }
- return rawFunctionObjMap;
+ return getFunctionForMap(ttpl, context, rawFunction, resolveGetInput);
}
} else if (rawFunctionObj instanceof ArrayList) { // In list type case
- // iterate over list properties in recursion, convert leaves to function,
- // and collect them in the same hierarchy as the original list.
- ArrayList<Object> rawFunctionObjList = new ArrayList<>();
- for (Object rawFunctionObjItem: (ArrayList) rawFunctionObj) {
- rawFunctionObjList.add(getFunction(ttpl, context, rawFunctionObjItem, resolveGetInput));
- }
- return rawFunctionObjList;
+ return getFunctionForList(ttpl, context, (ArrayList) rawFunctionObj, resolveGetInput);
}
return rawFunctionObj;
}
+ private static Object getFunctionForList(TopologyTemplate ttpl, Object context, ArrayList rawFunctionObj, boolean resolveGetInput) {
+ // iterate over list properties in recursion, convert leaves to function,
+ // and collect them in the same hierarchy as the original list.
+ ArrayList<Object> rawFunctionObjList = new ArrayList<>();
+ for (Object rawFunctionObjItem: rawFunctionObj) {
+ rawFunctionObjList.add(getFunction(ttpl, context, rawFunctionObjItem, resolveGetInput));
+ }
+ return rawFunctionObjList;
+ }
+
+ private static Object getFunctionForMap(TopologyTemplate ttpl, Object context, LinkedHashMap rawFunction, boolean resolveGetInput) {
+ // iterate over map nested properties in recursion, convert leaves to function,
+ // and collect them in the same hierarchy as the original map.
+ LinkedHashMap rawFunctionObjMap = new LinkedHashMap();
+ for (Object rawFunctionObjItem: rawFunction.entrySet()) {
+ Object itemValue = getFunction(ttpl, context, ((Map.Entry)rawFunctionObjItem).getValue(), resolveGetInput);
+ rawFunctionObjMap.put(((Map.Entry)rawFunctionObjItem).getKey(), itemValue);
+ }
+ return rawFunctionObjMap;
+ }
+
private static Object getFunctionForObjectItem(TopologyTemplate ttpl, Object context, Object rawFunctionObjItem, boolean resolveGetInput) {
if(isFunction(rawFunctionObjItem)) {
LinkedHashMap<String, Object> rawFunction = (LinkedHashMap<String, Object>) rawFunctionObjItem;