Replace deprecated methods in aai-common
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / introspection / JSONStrategy.java
index 484e561..2676d19 100644 (file)
 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;
 import java.util.UUID;
+
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.onap.aai.schema.enums.ObjectMetadata;
@@ -158,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;
         }
     }
@@ -167,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;
         }
     }