Replace deprecated methods in aai-common
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / introspection / JSONStrategy.java
index e628d5a..2676d19 100644 (file)
@@ -21,6 +21,7 @@
 package org.onap.aai.introspection;
 
 import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -147,9 +148,8 @@ public class JSONStrategy extends Introspector {
 
     @Override
     public Class<?> getGenericTypeClass(String name) {
-        Object resultObject = null;
         Class<?> resultClass = null;
-        resultObject = this.getValue(name);
+        Object resultObject = this.getValue(name);
         if (resultObject instanceof JSONArray) {
             resultClass = ((List) resultObject).get(0).getClass();
         }
@@ -160,8 +160,9 @@ public class JSONStrategy extends Introspector {
     @Override
     public Object newInstanceOfProperty(String name) {
         try {
-            return this.getClass(name).newInstance();
-        } catch (InstantiationException | IllegalAccessException e) {
+            return this.getClass(name).getDeclaredConstructor().newInstance();
+        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                | NoSuchMethodException | SecurityException e) {
             return null;
         }
     }
@@ -169,8 +170,9 @@ public class JSONStrategy extends Introspector {
     @Override
     public Object newInstanceOfNestedProperty(String name) {
         try {
-            return this.getGenericTypeClass(name).newInstance();
-        } catch (InstantiationException | IllegalAccessException e) {
+            return this.getGenericTypeClass(name).getDeclaredConstructor().newInstance();
+        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                | NoSuchMethodException | SecurityException e) {
             return null;
         }
     }
@@ -178,48 +180,25 @@ public class JSONStrategy extends Introspector {
     @Override
     public boolean isComplexType(String name) {
         String result = this.getType(name);
-
-        if (result.contains("JSONObject")) {
-            return true;
-        } else {
-            return false;
-        }
-
+        return result.contains("JSONObject");
     }
 
     @Override
     public boolean isComplexGenericType(String name) {
         String result = this.getGenericType(name);
-
-        if (result.contains("JSONObject")) {
-            return true;
-        } else {
-            return false;
-        }
-
+        return result.contains("JSONObject");
     }
 
     @Override
     public boolean isListType(String name) {
         String result = this.getType(name);
-
-        if (result.contains("java.util.List")) {
-            return true;
-        } else {
-            return false;
-        }
-
+        return result.contains("java.util.List");
     }
 
     @Override
     public boolean isContainer() {
         Set<String> props = this.getProperties();
-        boolean result = false;
-        if (props.size() == 1 && this.isListType(props.iterator().next())) {
-            result = true;
-        }
-
-        return result;
+        return props.size() == 1 && this.isListType(props.iterator().next());
     }
 
     @Override
@@ -265,12 +244,6 @@ public class JSONStrategy extends Introspector {
         return null;
     }
 
-    @Override
-    public Object clone() {
-        // TODO
-        return null;
-    }
-
     /*
      * @Override
      * public String findEdgeName(String parent, String child) {