Update license header in appc-dg-common files
[appc.git] / appc-dg / appc-dg-shared / appc-dg-common / src / main / java / org / onap / appc / dg / common / utils / JSONUtil.java
index 388295a..aa61ffc 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP : APPC
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
@@ -18,7 +18,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  * ============LICENSE_END=========================================================
  */
 
@@ -29,6 +28,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 
 import java.io.IOException;
 import java.io.Reader;
+import java.io.UncheckedIOException;
 import java.util.*;
 
 
@@ -36,12 +36,14 @@ public class JSONUtil {
 
     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
 
+    private JSONUtil() {}
+
     public static <T> T fromJson(String json, Class<T> clazz) {
 
         try {
             return OBJECT_MAPPER.readValue(json, clazz);
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new UncheckedIOException(e);
         }
     }
 
@@ -50,7 +52,7 @@ public class JSONUtil {
         try {
             return OBJECT_MAPPER.readValue(reader, clazz);
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new UncheckedIOException(e);
         }
     }
 
@@ -59,25 +61,23 @@ public class JSONUtil {
         try {
             return OBJECT_MAPPER.writeValueAsString(object);
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new UncheckedIOException(e);
         }
     }
 
-    public static Map<String,String> extractPlainValues(String json, String ... names) {
-        if (null == names) return Collections.emptyMap();
-        Map<String,String> values = new HashMap<>();
+    public static Map<String, String> extractPlainValues(String json, String... names) {
+        if (null == names) {
+            return Collections.emptyMap();
+        }
+        Map<String, String> values = new HashMap<>();
         try {
             final JsonNode jsonNode = OBJECT_MAPPER.readTree(json);
             for (String name : names) {
                 values.put(name, jsonNode.path(name).asText());
             }
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new UncheckedIOException(e);
         }
         return values;
     }
-
-
-
-
 }