summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-common-lib/src/main/java/org
diff options
context:
space:
mode:
authorshiria <shiri.amichai@amdocs.com>2018-03-21 09:11:30 +0200
committerOren Kleks <orenkle@amdocs.com>2018-03-21 12:24:17 +0000
commit298c383225d728eb6a04e4b8cb03472f4990de7e (patch)
tree5b975c4620ad350ff46060f1427a6accfc12ec2c /openecomp-be/lib/openecomp-common-lib/src/main/java/org
parentf59a22539d5b372e2425c39963547985379d6990 (diff)
Handle OperationDefinition in Tosca Data Model
Change-Id: Ib1a7f0c5548fc9c7a98cff1182ff02300353443d Issue-ID: SDC-1154 Signed-off-by: shiria <shiri.amichai@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-common-lib/src/main/java/org')
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
index 18750e4d0a..206eae3491 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
@@ -37,6 +37,7 @@ import org.openecomp.sdc.common.errors.Messages;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -176,11 +177,34 @@ public class CommonUtil {
Map<String, Object> objectAsMap = getObjectAsMap(objectCandidate);
T result = classToCreate.newInstance();
+
+ Field[] declaredFields = classToCreate.getDeclaredFields();
+ for( Field field : declaredFields){
+ if(isComplexClass(field)){
+ Optional<?> objectUsingSetters =
+ createObjectUsingSetters(objectAsMap.get(field.getName()), field.getType());
+ if( objectUsingSetters.isPresent()){
+ objectAsMap.remove(field.getName());
+ objectAsMap.put(field.getName(), objectUsingSetters.get());
+ }
+ }
+ }
BeanUtils.populate(result, objectAsMap);
return Optional.of(result);
}
+ private static boolean isComplexClass(Field field) {
+ return !field.getType().equals(Map.class)
+ && !field.getType().equals(String.class)
+ && !field.getType().equals(Integer.class)
+ && !field.getType().equals(Float.class)
+ && !field.getType().equals(Double.class)
+ && !field.getType().equals(Set.class)
+ && !field.getType().equals(Object.class)
+ && !field.getType().equals(List.class);
+ }
+
public static Map<String, Object> getObjectAsMap(Object obj) {
Map<String, Object> objectAsMap = obj instanceof Map ? (Map<String, Object>) obj
: new ObjectMapper().convertValue(obj, Map.class);