summaryrefslogtreecommitdiffstats
path: root/model/utilities
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-07-30 16:06:49 -0400
committerJim Hahn <jrh3@att.com>2021-08-02 09:42:54 -0400
commit038c19d4042de980d4adccbfa82c1534b53abe5f (patch)
treeda447592a6a90c2d869e34642712edf4413dc6c1 /model/utilities
parent1036206455218a4722079b749e628ca96825418d (diff)
Use lombok annotations in apex-pdp
Updated projects: services-engine through utilities Issue-ID: POLICY-3391 Change-Id: I35ebb40d86e9bda360f7819516290b3fea88335c Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'model/utilities')
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java10
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java12
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java12
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java28
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java52
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java14
6 files changed, 35 insertions, 93 deletions
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
index 190b270ea..8ca6d153e 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
@@ -23,18 +23,16 @@ package org.onap.policy.apex.model.utilities;
import java.util.List;
import java.util.ListIterator;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
/**
* This is common utility class with static methods for handling collections.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class CollectionUtils {
- /**
- * Private constructor used to prevent sub class instantiation.
- */
- private CollectionUtils() {
- }
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class CollectionUtils {
/**
* Compare two lists, checks for equality, then for equality on members.
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
index 011dbb1b2..cc92d2a7f 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 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.
@@ -22,6 +23,8 @@
package org.onap.policy.apex.model.utilities;
import java.io.File;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -31,17 +34,12 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public abstract class DirectoryUtils {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DirectoryUtils {
// Get a reference to the logger
private static final XLogger LOGGER = XLoggerFactory.getXLogger(DirectoryUtils.class);
/**
- * Private constructor used to prevent sub class instantiation.
- */
- private DirectoryUtils() {
- }
-
- /**
* Method to get an empty temporary directory in the system temporary directory on the local machine that will be
* deleted on (normal) shutdown.
*
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java
index d48f7f951..6daa6864a 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java
@@ -26,6 +26,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.NavigableMap;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
/**
* This class provides utility functions for tree maps. A function to find the nearest match in the tree map to an input
@@ -33,14 +35,8 @@ import java.util.NavigableMap;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TreeMapUtils {
-
- /**
- * This class is a utility class that can't be instantiated.
- */
- private TreeMapUtils() {
- // Private constructor to block subclassing
- }
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class TreeMapUtils {
/**
* Find the list of entries that matches a given word, for example "p" will match "put", "policy", and "push".
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
index 2eb6af894..b01c83d59 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
@@ -1,25 +1,28 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.utilities.comparison;
+import lombok.Getter;
+
/**
* This class is used to template key differences for bulk key comparisons in models. It performs a difference check
* between two keys.
@@ -27,6 +30,7 @@ package org.onap.policy.apex.model.utilities.comparison;
* @author Liam Fallon (liam.fallon@ericsson.com)
* @param <K> the generic type
*/
+@Getter
public class KeyDifference<K> {
// The keys being compared
private K leftKey;
@@ -44,24 +48,6 @@ public class KeyDifference<K> {
}
/**
- * Gets the left key.
- *
- * @return the left key
- */
- public K getLeftKey() {
- return leftKey;
- }
-
- /**
- * Gets the right key.
- *
- * @return the right key
- */
- public K getRightKey() {
- return rightKey;
- }
-
- /**
* Checks if the left and right keys are equal.
*
* @return true, if checks if is equal
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
index 91c523ed1..a070ec9ce 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
@@ -1,19 +1,20 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -24,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
+import lombok.Getter;
/**
* This class holds the result of a difference check between two keyed maps. Four results are returned in the class. The
@@ -36,6 +38,7 @@ import java.util.TreeMap;
* @param <K> the generic type
* @param <V> the generic type
*/
+@Getter
public class KeyedMapDifference<K, V> {
private static final String KEY = "key=";
private static final String VALUE = ",value=";
@@ -47,43 +50,6 @@ public class KeyedMapDifference<K, V> {
private Map<K, List<V>> differentValues = new TreeMap<>();
/**
- * Gets the entries that were found only in the left map.
- *
- * @return the entries only in the left map
- */
- public Map<K, V> getLeftOnly() {
- return leftOnly;
- }
-
- /**
- * Gets the entries that were found only in the right map.
- *
- * @return the entries only in the right map
- */
- public Map<K, V> getRightOnly() {
- return rightOnly;
- }
-
- /**
- * Gets the entries that were identical (keys and values the same) in both maps.
- *
- * @return the identical entries
- */
- public Map<K, V> getIdenticalValues() {
- return identicalValues;
- }
-
- /**
- * Gets the entries that had the same key but different values in both maps.
- *
- * @return the entries that were different. There are two values in the list of values for each entry. The first
- * value is the value that was in the left map and the second value is the value that was in the right map.
- */
- public Map<K, List<V>> getDifferentValues() {
- return differentValues;
- }
-
- /**
* Return a string representation of the differences.
*
* @param diffsOnly if set, then a blank string is returned if the maps are equal
@@ -127,7 +93,7 @@ public class KeyedMapDifference<K, V> {
/**
* Output the entries in a map with entries that are in one side only as a string.
- *
+ *
* @param sideMap the map for the side being checked
* @param sideMapString the string that represents the map in output strings
* @param keysOnly if true, just add key information and not entries
@@ -153,7 +119,7 @@ public class KeyedMapDifference<K, V> {
/**
* Output the differences between two the maps as a string.
- *
+ *
* @param keysOnly if true, just add key information and not entries
* @return the differences as a string
*/
@@ -185,7 +151,7 @@ public class KeyedMapDifference<K, V> {
/**
* Output the identical entries in the maps as a string.
- *
+ *
* @param keysOnly if true, just add key information and not entries
* @return the identical entries as a string
*/
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java
index bc0551c57..66e389fa2 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -33,6 +34,7 @@ import java.io.Reader;
* @param <P> the generic type
*/
public class JsonHandler<P> {
+ private static final Gson GSON = new GsonBuilder().serializeNulls().create();
/**
* This method reads objects of a given class from an input stream.
@@ -42,11 +44,7 @@ public class JsonHandler<P> {
* @return the object read
*/
public P read(final Class<P> inputClass, final InputStream inputStream) {
- // Register the adapters for our carrier technologies and event protocols with GSON
- final GsonBuilder gsonBuilder = new GsonBuilder();
-
- final Gson gson = gsonBuilder.serializeNulls().create();
final Reader jsonResourceReader = new InputStreamReader(inputStream);
- return gson.fromJson(jsonResourceReader, inputClass);
+ return GSON.fromJson(jsonResourceReader, inputClass);
}
}