Imp Modules refactored for the readthedocs
[so.git] / adapters / mso-vfc-adapter / src / main / java / org / openecomp / mso / adapters / vfc / util / JsonUtil.java
index a9546d5..69ad951 100644 (file)
@@ -40,93 +40,93 @@ import org.openecomp.mso.logger.MsoLogger;
  */
 public class JsonUtil {
 
-    /**
-     * Log service
-     */
-    private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+  /**
+   * Log service
+   */
+  private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
 
-    /**
-     * Mapper.
-     */
-    private static final ObjectMapper MAPPER = new ObjectMapper();
+  /**
+   * Mapper.
+   */
+  private static final ObjectMapper MAPPER = new ObjectMapper();
 
-    static {
-        MAPPER.setDeserializationConfig(MAPPER.getDeserializationConfig()
-                .without(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES));
-        MAPPER.setSerializationInclusion(Inclusion.NON_NULL);
-    }
+  static {
+    MAPPER.setDeserializationConfig(MAPPER.getDeserializationConfig().without(
+        org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES));
+    MAPPER.setSerializationInclusion(Inclusion.NON_NULL);
+  }
 
-    /**
-     * Constructor<br/>
-     * <p>
-     * </p>
-     
-     * @since ONAP Amsterdam Release 2017-9-6
-     */
-    private JsonUtil() {
+  /**
+   * Constructor<br/>
+   * <p>
+   * </p>
+   * 
+   * @since ONAP Amsterdam Release 2017-9-6
+   */
+  private JsonUtil() {
 
-    }
+  }
 
-    /**
-     * Parse the string in form of json.<br/>
-     * 
-     * @param jsonstr json string.
-     * @param type that convert json string to
-     * @return model object
-     * @since ONAP Amsterdam Release 2017-9-6
-     */
-    public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException {
-        try {
-            return MAPPER.readValue(jsonstr, type);
-        } catch(IOException e) {
-            LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
-                    "fail to unMarshal json", e);
-            throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
-        }
+  /**
+   * Parse the string in form of json.<br/>
+   * 
+   * @param jsonstr json string.
+   * @param type that convert json string to
+   * @return model object
+   * @since ONAP Amsterdam Release 2017-9-6
+   */
+  public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException {
+    try {
+      return MAPPER.readValue(jsonstr, type);
+    } catch (IOException e) {
+      LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
+          "fail to unMarshal json", e);
+      throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
     }
+  }
 
-    /**
-     * Parse the string in form of json.<br/>
-     * 
-     * @param jsonstr json string.
-     * @param type that convert json string to
-     * @return model object
-     * @since ONAP Amsterdam Release 2017-9-6
-     */
-    public static <T> T unMarshal(String jsonstr, TypeReference<T> type) throws ApplicationException {
-        try {
-            return MAPPER.readValue(jsonstr, type);
-        } catch(IOException e) {
-            LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
-                    "fail to unMarshal json", e);
-            throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
-        }
+  /**
+   * Parse the string in form of json.<br/>
+   * 
+   * @param jsonstr json string.
+   * @param type that convert json string to
+   * @return model object
+   * @since ONAP Amsterdam Release 2017-9-6
+   */
+  public static <T> T unMarshal(String jsonstr, TypeReference<T> type) throws ApplicationException {
+    try {
+      return MAPPER.readValue(jsonstr, type);
+    } catch (IOException e) {
+      LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
+          "fail to unMarshal json", e);
+      throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
     }
+  }
 
-    /**
-     * Convert object to json string.<br/>
-     * 
-     * @param srcObj data object
-     * @return json string
-     * @since ONAP Amsterdam Release 2017-9-6
-     */
-    public static String marshal(Object srcObj) throws ApplicationException {
-        try {
-            return MAPPER.writeValueAsString(srcObj);
-        } catch(IOException e) {
-            LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
-                    "fail to marshal json", e);
-            throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!");
-        }
+  /**
+   * Convert object to json string.<br/>
+   * 
+   * @param srcObj data object
+   * @return json string
+   * @since ONAP Amsterdam Release 2017-9-6
+   */
+  public static String marshal(Object srcObj) throws ApplicationException {
+    try {
+      return MAPPER.writeValueAsString(srcObj);
+    } catch (IOException e) {
+      LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
+          "fail to marshal json", e);
+      throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!");
     }
+  }
 
-    /**
-     * Get mapper.<br/>
-     
-     * @return mapper
-     * @since ONAP Amsterdam Release 2017-9-6
-     */
-    public static ObjectMapper getMapper() {
-        return MAPPER;
-    }
+  /**
+   * Get mapper.<br/>
+   * 
+   * @return mapper
+   * @since ONAP Amsterdam Release 2017-9-6
+   */
+  public static ObjectMapper getMapper() {
+    return MAPPER;
+  }
 }