TCA: Replace any openecomp reference by onap
[dcaegen2/analytics/tca.git] / dcae-analytics-model / src / main / java / org / onap / dcae / apod / analytics / model / util / json / AnalyticsModelObjectMapperSupplier.java
-/*\r
- * ===============================LICENSE_START======================================\r
- *  dcae-analytics\r
- * ================================================================================\r
- *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *   You may obtain a copy of the License at\r
- *\r
- *          http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
- *  ============================LICENSE_END===========================================\r
- */\r
-\r
-package org.openecomp.dcae.apod.analytics.model.util.json;\r
-\r
-import com.fasterxml.jackson.annotation.JsonInclude;\r
-import com.fasterxml.jackson.databind.DeserializationFeature;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.google.common.base.Supplier;\r
-import com.jayway.jsonpath.Configuration;\r
-import com.jayway.jsonpath.JsonPath;\r
-import com.jayway.jsonpath.Option;\r
-import com.jayway.jsonpath.spi.json.JacksonJsonProvider;\r
-import com.jayway.jsonpath.spi.json.JsonProvider;\r
-import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;\r
-import com.jayway.jsonpath.spi.mapper.MappingProvider;\r
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;\r
-\r
-import java.util.EnumSet;\r
-import java.util.Set;\r
-\r
-/**\r
- *<p>\r
- *     {@link Supplier} that can be used by clients to get Object Mapper which specializes\r
- *     in serialize and deserialize - DCAE Analytics Model JSON Objects. Clients can\r
- *     choose to memoize this Supplier for performance enhancements\r
- *     <br>\r
- *     NOTE: This supplier also setups up {@link JsonPath} default\r
- *     config to make use of this Supplier object mapper\r
- *</p>\r
- * @author Rajiv Singla . Creation Date: 11/10/2016.\r
- */\r
-@SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC_ANON")\r
-public class AnalyticsModelObjectMapperSupplier implements Supplier<ObjectMapper> {\r
-\r
-    @Override\r
-    public ObjectMapper get() {\r
-\r
-        final ObjectMapper objectMapper = new ObjectMapper();\r
-\r
-        // Serialize null values\r
-        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);\r
-\r
-        // Don't fail on unknown properties\r
-        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);\r
-\r
-        // Register Common Event Format Module\r
-        objectMapper.registerModule(new CommonEventFormatModule());\r
-        // Register TCA Policy Module\r
-        objectMapper.registerModule(new TCAPolicyModule());\r
-        // Register TCA Facade Module\r
-        objectMapper.registerModule(new TCAFacadeModelModule());\r
-        // Register TCA Controller App Config Module\r
-        objectMapper.registerModule(new TCAControllerConfigModule());\r
-\r
-\r
-        // Setup JsonPath default config\r
-        setupJsonPathDefaultConfig(objectMapper);\r
-\r
-        return objectMapper;\r
-    }\r
-\r
-\r
-    /**\r
-     * Setups up default Config for {@link JsonPath}\r
-     *\r
-     * @param objectMapper Jackson object mapper\r
-     */\r
-    private void setupJsonPathDefaultConfig(final ObjectMapper objectMapper) {\r
-\r
-        Configuration.setDefaults(new Configuration.Defaults() {\r
-\r
-            private final JsonProvider jsonProvider = new JacksonJsonProvider(objectMapper);\r
-            private final MappingProvider mappingProvider = new JacksonMappingProvider(objectMapper);\r
-\r
-            @Override\r
-            public JsonProvider jsonProvider() {\r
-                return jsonProvider;\r
-            }\r
-\r
-            @Override\r
-            public MappingProvider mappingProvider() {\r
-                return mappingProvider;\r
-            }\r
-\r
-            @Override\r
-            public Set<Option> options() {\r
-\r
-                // Json Path exceptions are suppressed, also missing properties are tolerated\r
-                return EnumSet.of(Option.DEFAULT_PATH_LEAF_TO_NULL, Option.SUPPRESS_EXCEPTIONS,\r
-                        Option.ALWAYS_RETURN_LIST);\r
-            }\r
-        });\r
-\r
-\r
-    }\r
-\r
-}\r
+/*
+ * ===============================LICENSE_START======================================
+ *  dcae-analytics
+ * ================================================================================
+ *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  ============================LICENSE_END===========================================
+ */
+
+package org.onap.dcae.apod.analytics.model.util.json;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Supplier;
+import com.jayway.jsonpath.Configuration;
+import com.jayway.jsonpath.JsonPath;
+import com.jayway.jsonpath.Option;
+import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
+import com.jayway.jsonpath.spi.json.JsonProvider;
+import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
+import com.jayway.jsonpath.spi.mapper.MappingProvider;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+/**
+ *<p>
+ *     {@link Supplier} that can be used by clients to get Object Mapper which specializes
+ *     in serialize and deserialize - DCAE Analytics Model JSON Objects. Clients can
+ *     choose to memoize this Supplier for performance enhancements
+ *     <br>
+ *     NOTE: This supplier also setups up {@link JsonPath} default
+ *     config to make use of this Supplier object mapper
+ *</p>
+ * @author Rajiv Singla . Creation Date: 11/10/2016.
+ */
+@SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC_ANON")
+public class AnalyticsModelObjectMapperSupplier implements Supplier<ObjectMapper> {
+
+    @Override
+    public ObjectMapper get() {
+
+        final ObjectMapper objectMapper = new ObjectMapper();
+
+        // Serialize null values
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+        // Don't fail on unknown properties
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+        // Register Common Event Format Module
+        objectMapper.registerModule(new CommonEventFormatModule());
+        // Register TCA Policy Module
+        objectMapper.registerModule(new TCAPolicyModule());
+        // Register TCA Facade Module
+        objectMapper.registerModule(new TCAFacadeModelModule());
+        // Register TCA Controller App Config Module
+        objectMapper.registerModule(new TCAControllerConfigModule());
+
+
+        // Setup JsonPath default config
+        setupJsonPathDefaultConfig(objectMapper);
+
+        return objectMapper;
+    }
+
+
+    /**
+     * Setups up default Config for {@link JsonPath}
+     *
+     * @param objectMapper Jackson object mapper
+     */
+    private void setupJsonPathDefaultConfig(final ObjectMapper objectMapper) {
+
+        Configuration.setDefaults(new Configuration.Defaults() {
+
+            private final JsonProvider jsonProvider = new JacksonJsonProvider(objectMapper);
+            private final MappingProvider mappingProvider = new JacksonMappingProvider(objectMapper);
+
+            @Override
+            public JsonProvider jsonProvider() {
+                return jsonProvider;
+            }
+
+            @Override
+            public MappingProvider mappingProvider() {
+                return mappingProvider;
+            }
+
+            @Override
+            public Set<Option> options() {
+
+                // Json Path exceptions are suppressed, also missing properties are tolerated
+                return EnumSet.of(Option.DEFAULT_PATH_LEAF_TO_NULL, Option.SUPPRESS_EXCEPTIONS,
+                        Option.ALWAYS_RETURN_LIST);
+            }
+        });
+
+
+    }
+
+}