Replace deprecated methods in aai-common
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / introspection / Introspector.java
index 117610f..87983d8 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.onap.aai.introspection;
 
+import com.google.common.base.CaseFormat;
+
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
@@ -48,8 +50,6 @@ import org.onap.aai.workarounds.NamingExceptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.CaseFormat;
-
 public abstract class Introspector implements Cloneable {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(Introspector.class);
@@ -103,9 +103,10 @@ public abstract class Introspector implements Cloneable {
         Class<?> clazz = this.getClass(name);
         if (this.isListType(name) && result == null) {
             try {
-                this.set(convertedName, clazz.newInstance());
+                this.set(convertedName, clazz.getDeclaredConstructor().newInstance());
                 result = this.get(convertedName);
-            } catch (DynamicException | InstantiationException | IllegalAccessException e) {
+            } catch (DynamicException | InstantiationException | IllegalAccessException | IllegalArgumentException
+                    | InvocationTargetException | NoSuchMethodException | SecurityException e) {
                 LOGGER.warn(e.getMessage(), e);
             }
         }
@@ -127,9 +128,10 @@ public abstract class Introspector implements Cloneable {
         Class<?> clazz = this.getClass(name);
         if (this.isListType(name) && value == null) {
             try {
-                this.set(convertedName, clazz.newInstance());
+                this.set(convertedName, clazz.getDeclaredConstructor().newInstance());
                 value = this.get(convertedName);
-            } catch (DynamicException | InstantiationException | IllegalAccessException e) {
+            } catch (DynamicException | InstantiationException | IllegalAccessException | IllegalArgumentException
+                    | InvocationTargetException | NoSuchMethodException | SecurityException e) {
                 LOGGER.warn(e.getMessage(), e);
             }
         }
@@ -159,9 +161,10 @@ public abstract class Introspector implements Cloneable {
         Class<?> clazz = this.getClass(name);
         if (isListType && value == null) {
             try {
-                this.set(convertedName, clazz.newInstance());
+                this.set(convertedName, clazz.getDeclaredConstructor().newInstance());
                 value = this.get(convertedName);
-            } catch (DynamicException | InstantiationException | IllegalAccessException e) {
+            } catch (DynamicException | InstantiationException | IllegalAccessException | IllegalArgumentException
+                    | InvocationTargetException | NoSuchMethodException | SecurityException e) {
                 LOGGER.warn(e.getMessage(), e);
             }
         }
@@ -185,7 +188,7 @@ public abstract class Introspector implements Cloneable {
         if (obj != null) {
 
             try {
-                if (! (obj.getClass().getCanonicalName().equals(nameClass.getCanonicalName()))) {
+                if (!(obj.getClass().getCanonicalName().equals(nameClass.getCanonicalName()))) {
                     if (nameClass.isPrimitive()) {
                         nameClass = ClassUtils.primitiveToWrapper(nameClass);
                         result = nameClass.getConstructor(String.class).newInstance(obj.toString());
@@ -317,8 +320,7 @@ public abstract class Introspector implements Cloneable {
             String indexedKeys = this.getMetadata(ObjectMetadata.INDEXED_PROPS);
             if (dslKeys != null) {
                 Arrays.stream(dslKeys.split(",")).forEach(result::add);
-            }
-            else if(indexedKeys != null){
+            } else if (indexedKeys != null) {
                 Arrays.stream(indexedKeys.split(",")).forEach(result::add);
             }
             this.dslStartNodeProperties = Collections.unmodifiableSet(result);