Reduce nest statement levels

Reduce the if/for/switch/try nest statement levels to less than 3.

Issue-ID: SDC-3119
Signed-off-by: xuegao <xg353y@intl.att.com>
Change-Id: I60f0c0203db4495c6e10127114acdb8586867b14
Signed-off-by: xuegao <xg353y@intl.att.com>
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
index 0a5a141..5d49fa9 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
@@ -435,17 +435,18 @@
             field.setAccessible(true);
             Config fieldConfAnnotation = field.getAnnotation(Config.class);
             Class<?> fieldType = field.getType();
-            if (fieldConfAnnotation != null) {
-                if (ConfigurationUtils.isAPrimitiveOrWrapper(fieldType) ||
-                        ConfigurationUtils.isAPrimitivesOrWrappersArray(fieldType)) {
-                    setPrimitiveField(field, objToReturn, tenant, namespace, keyPrefix, hints);
-                }
-                if (ConfigurationUtils.isACollection(fieldType)) {
-                    setCollectionField(field, objToReturn, tenant, namespace, keyPrefix, hints);
-                }
-                if (ConfigurationUtils.isAMap(fieldType)) {
-                    setMapField(field, objToReturn, tenant, namespace, keyPrefix);
-                }
+            if (fieldConfAnnotation == null) {
+                continue;
+            }
+            if (ConfigurationUtils.isAPrimitiveOrWrapper(fieldType) ||
+                ConfigurationUtils.isAPrimitivesOrWrappersArray(fieldType)) {
+                setPrimitiveField(field, objToReturn, tenant, namespace, keyPrefix, hints);
+            }
+            if (ConfigurationUtils.isACollection(fieldType)) {
+                setCollectionField(field, objToReturn, tenant, namespace, keyPrefix, hints);
+            }
+            if (ConfigurationUtils.isAMap(fieldType)) {
+                setMapField(field, objToReturn, tenant, namespace, keyPrefix);
             }
         }
         return objToReturn;
@@ -471,30 +472,31 @@
         Object obj = get(tenant, namespace, keyPrefix + fieldConfAnnotationKey,
                 ConfigurationUtils.getArrayClass(ConfigurationUtils.getCollectionGenericType(field)),
                 hints);
-        if (obj != null) {
-            List<Object> list = Arrays.asList((Object[]) obj);
-            Class clazzToInstantiate;
-            if (fieldType.isInterface()) {
-                clazzToInstantiate = ConfigurationUtils.getConcreteCollection(fieldType).getClass();
-            } else if (Modifier.isAbstract(fieldType.getModifiers())) {
-                clazzToInstantiate =
-                        ConfigurationUtils.getCompatibleCollectionForAbstractDef(fieldType)
-                                .getClass();
-            } else {
-                clazzToInstantiate = fieldType;
-            }
-            Constructor construct = getConstructorWithArguments(clazzToInstantiate, Collection.class);
+        if (obj == null) {
+            return;
+        }
+        List<Object> list = Arrays.asList((Object[]) obj);
+        Class clazzToInstantiate;
+        if (fieldType.isInterface()) {
+            clazzToInstantiate = ConfigurationUtils.getConcreteCollection(fieldType).getClass();
+        } else if (Modifier.isAbstract(fieldType.getModifiers())) {
+            clazzToInstantiate =
+                    ConfigurationUtils.getCompatibleCollectionForAbstractDef(fieldType)
+                            .getClass();
+        } else {
+            clazzToInstantiate = fieldType;
+        }
+        Constructor construct = getConstructorWithArguments(clazzToInstantiate, Collection.class);
 
+        if (construct != null) {
+            construct.setAccessible(true);
+            field.set(objToReturn, construct.newInstance(list));
+        } else {
+            construct = getConstructorWithArguments(clazzToInstantiate, Integer.class,
+                   Boolean.class, Collection.class);
             if (construct != null) {
                 construct.setAccessible(true);
-                field.set(objToReturn, construct.newInstance(list));
-            } else {
-                construct = getConstructorWithArguments(clazzToInstantiate, Integer.class,
-                        Boolean.class, Collection.class);
-                if (construct != null) {
-                    construct.setAccessible(true);
-                    field.set(objToReturn, construct.newInstance(list.size(), true, list));
-                }
+                field.set(objToReturn, construct.newInstance(list.size(), true, list));
             }
         }
     }