summaryrefslogtreecommitdiffstats
path: root/model/utilities/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-02-10 12:06:25 +0000
committerliamfallon <liam.fallon@est.tech>2022-02-10 13:48:15 +0000
commit8534756d13531ffec9c2d7b2ffe0a53ee1d3aaef (patch)
treea35f6b3f7766d47900ee6691111acff1418bb747 /model/utilities/src/main
parent2f2c5465cd23c8c3300a5c3d185806bb3e7d73c1 (diff)
Collapse apex-pdp maven model submodules
This review collapses all the code in six podel submodules into a single model module. There are no code changes, just files moved around. This change reduces the complexity of the code structure and speeds up the build. Issue-ID: POLICY-1820 Change-Id: Ifb644e8ec85ae6d0987378f4616fbc8a8858a9a8 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'model/utilities/src/main')
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java109
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java67
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java110
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java126
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyComparer.java42
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java86
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java96
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java174
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/package-info.java26
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java50
-rwxr-xr-xmodel/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/package-info.java26
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/package-info.java26
12 files changed, 0 insertions, 938 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
deleted file mode 100644
index 9636ea7ce..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * ============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;
-
-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)
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class CollectionUtils {
-
- /**
- * Compare two lists, checks for equality, then for equality on members.
- *
- * @param <T> The type of the lists being compared
- * @param leftList The leftmost List
- * @param rightList The rightmost list
- * @return an integer indicating how different the lists are
- */
- public static <T> int compareLists(final List<? extends Comparable<T>> leftList,
- final List<? extends Comparable<T>> rightList) {
- // Check for nulls
- if (leftList == null && rightList == null) {
- return 0;
- }
- if (leftList != null && rightList == null) {
- return -1;
- }
- if (leftList == null) {
- return 1;
- }
-
- // Check for equality
- if (leftList.equals(rightList)) {
- return 0;
- }
-
- return compareListEntries(leftList, rightList);
- }
-
- /**
- * Compare two lists for equality on members.
- *
- * @param <T> The type of the lists being compared
- * @param leftList The leftmost List
- * @param rightList The rightmost list
- * @return an integer indicating how different the lists are
- */
- private static <T> int compareListEntries(final List<? extends Comparable<T>> leftList,
- final List<? extends Comparable<T>> rightList) {
-
- // Iterate down the lists till we find a difference
- final ListIterator<?> leftIterator = leftList.listIterator();
- final ListIterator<?> rightIterator = rightList.listIterator();
-
- while (true) {
- // Check the iterators
- if (!leftIterator.hasNext() && !rightIterator.hasNext()) {
- return 0;
- }
- if (leftIterator.hasNext() && !rightIterator.hasNext()) {
- return -1;
- }
- if (!leftIterator.hasNext() && rightIterator.hasNext()) {
- return 1;
- }
-
- // Get the next objects
- @SuppressWarnings("unchecked")
- final var leftObject = (T) leftIterator.next();
- @SuppressWarnings("unchecked")
- final var rightObject = (T) rightIterator.next();
-
- // Compare the objects
- @SuppressWarnings("unchecked")
- final int comparisonResult = ((Comparable<T>) leftObject).compareTo(rightObject);
-
- // Check the comparison result
- if (comparisonResult != 0) {
- return comparisonResult;
- }
- }
- }
-}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java
deleted file mode 100644
index 21c417c4d..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 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.
- * 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;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class DirectoryShutdownHook removes the contents of a directory and the directory itself at shutdown.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-final class DirectoryDeleteShutdownHook extends Thread {
-
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(DirectoryUtils.class);
-
- // The directory we are acting on
- private final File tempDir;
-
- /**
- * Constructor that defines the directory to act on at shutdown.
- *
- * @param tempDir The temporary directory to delete
- */
- DirectoryDeleteShutdownHook(final File tempDir) {
- this.tempDir = tempDir;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void run() {
- if (tempDir.exists()) {
- // Empty and delete the directory
- DirectoryUtils.emptyDirectory(tempDir);
- try {
- Files.delete(tempDir.toPath());
- } catch (IOException e) {
- LOGGER.warn("Failed to delete directory {}", tempDir, e);
- }
- }
- }
-}
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
deleted file mode 100644
index b0e8332b1..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * ============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.
- * 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;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * This is common utility class with static methods for handling directories. It is an abstract class to prevent any
- * direct instantiation and private constructor to prevent extending this class.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class DirectoryUtils {
- // Get a reference to the logger
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(DirectoryUtils.class);
-
- /**
- * Method to get an empty temporary directory in the system temporary directory on the local machine that will be
- * deleted on (normal) shutdown.
- *
- * @param nameprefix The prefix of the filename. System.nanoTime() will be appended to the pattern to create a
- * unique file pattern
- * @return The temporary directory
- */
- public static File getLocalTempDirectory(final String nameprefix) {
- try {
- // Get the name of the temporary directory
- final String tempDirName = System.getProperty("java.io.tmpdir") + "/" + nameprefix + System.nanoTime();
- final var tempDir = new File(tempDirName);
-
- // Delete the directory if it already exists
- if (tempDir.exists()) {
- return null;
- }
-
- // Make the directory
- tempDir.mkdirs();
-
- // Add a shutdown hook that deletes the directory contents when the JVM closes
- Runtime.getRuntime().addShutdownHook(new DirectoryDeleteShutdownHook(tempDir));
-
- LOGGER.trace("creating temp directory\"{}\" : ", tempDir.getAbsolutePath());
- return tempDir;
- } catch (final Exception e) {
- LOGGER.debug("error creating temp directory\"{}\" : " + e.getMessage(), e);
- return null;
- }
- }
-
- /**
- * Method to recursively delete all the files in a directory.
- *
- * @param tempDir the directory to empty
- * @return true if the operation succeeds, false otherwise
- */
- public static boolean emptyDirectory(final File tempDir) {
- // Sanity check
- if (!tempDir.exists() || !tempDir.isDirectory()) {
- return false;
- }
-
- // Walk the directory structure deleting files as we go
- final File[] files = tempDir.listFiles();
- if (files != null) {
- for (final File directoryFile : files) {
- // Check if this is a directory itself
- if (directoryFile.isDirectory()) {
- // Recurse into the sub directory and empty it
- emptyDirectory(directoryFile);
- }
-
- // Delete the directory entry
- try {
- Files.delete(directoryFile.toPath());
- } catch (IOException e) {
- LOGGER.warn("Failed to delete directory file {}", directoryFile, e);
- }
- }
- }
-
- return true;
- }
-}
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
deleted file mode 100644
index d8bb469cf..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*-
- * ============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;
-
-import java.util.AbstractMap.SimpleEntry;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-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
- * string is provided.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-@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".
- *
- * @param <T> the generic type for the value of the tree map
- * @param searchMap the map that the method operates on
- * @param word the word to search for
- * @return the list of entries in the {@code searchMap} that match the {@code word}
- */
- public static <T> List<Entry<String, T>> findMatchingEntries(final NavigableMap<String, T> searchMap,
- final String word) {
- final List<Entry<String, T>> foundNodes = new ArrayList<>();
-
- // A straight match check
- if (searchMap.containsKey(word)) {
- foundNodes.add(new SimpleEntry<>(word, searchMap.get(word)));
- return foundNodes;
- }
-
- // Set up the beginning point for our search for a list of near matches
- String foundKeyword = searchMap.floorKey(word);
- if (foundKeyword == null) {
- foundKeyword = searchMap.firstKey();
- } else {
- foundKeyword = searchMap.higherKey(foundKeyword);
- }
-
- // Find all the nodes that start with the word we are searching for
- while (foundKeyword != null) {
- if (foundKeyword.startsWith(word)) {
- foundNodes.add(new SimpleEntry<>(foundKeyword, searchMap.get(foundKeyword)));
- foundKeyword = searchMap.higherKey(foundKeyword);
- } else {
- break;
- }
- }
- return foundNodes;
- }
-
- /**
- * Compares two maps.
- * @param <K> Key type
- * @param <V> Value type
- * @param leftMap left map
- * @param rightMap right map
- * @return an integer indicating how different the maps are
- */
- @SuppressWarnings("unchecked")
- public static <K, V> int compareMaps(Map<? extends Comparable<K>, ? extends Comparable<V>> leftMap,
- Map<? extends Comparable<K>, ? extends Comparable<V>> rightMap) {
- if (leftMap == rightMap) {
- return 0;
- }
-
- Iterator<?> leftIt = leftMap.entrySet().iterator();
- Iterator<?> rightIt = rightMap.entrySet().iterator();
-
- while (leftIt.hasNext() && rightIt.hasNext()) {
- Map.Entry<?, ?> leftEntry = (Entry<?, ?>) leftIt.next();
- Map.Entry<?, ?> rightEntry = (Entry<?, ?>) rightIt.next();
-
- var leftKey = (K) leftEntry.getKey();
- var rightKey = (K) rightEntry.getKey();
- int result = ((Comparable<K>) leftKey).compareTo(rightKey);
- if (result != 0) {
- return result;
- }
-
- var leftValue = (V) leftEntry.getValue();
- var rightValue = (V) rightEntry.getValue();
- result = ((Comparable<V>) leftValue).compareTo(rightValue);
- if (result != 0) {
- return result;
- }
- }
-
- if (leftIt.hasNext()) {
- return 1;
- } else if (rightIt.hasNext()) {
- return -1;
- } else {
- return 0;
- }
- }
-}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyComparer.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyComparer.java
deleted file mode 100644
index f4d628405..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyComparer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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;
-
-/**
- * This class compares two keys and returns their differences. It is used in bulk comparisons in models where maps of
- * keys are being compared. The {@link KeyComparer} that is returned does the actual comparison
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <K> the type of key being compared
- */
-public class KeyComparer<K> {
-
- /**
- * Compare two keys and return their differences.
- *
- * @param leftKey The left key of the comparison
- * @param rightKey The right key of the comparison
- * @return The difference between the keys
- */
- public KeyDifference<K> compareKeys(final K leftKey, final K rightKey) {
- return new KeyDifference<>(leftKey, rightKey);
- }
-}
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
deleted file mode 100644
index a0395cf16..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * ============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.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <K> the generic type
- */
-@Getter
-public class KeyDifference<K> {
- // The keys being compared
- private K leftKey;
- private K rightKey;
-
- /**
- * Constructor used to set the keys being compared.
- *
- * @param leftKey the left key that is being compared
- * @param rightKey the right key that is being compared
- */
- public KeyDifference(final K leftKey, final K rightKey) {
- this.leftKey = leftKey;
- this.rightKey = rightKey;
- }
-
- /**
- * Checks if the left and right keys are equal.
- *
- * @return true, if checks if is equal
- */
- public boolean isEqual() {
- return leftKey.equals(rightKey);
- }
-
- /**
- * Gets a string representation of the difference between the keys.
- *
- * @param diffsOnly if set, then a blank string is returned if the keys are equal
- * @return the difference between the keys as a string
- */
- public String asString(final boolean diffsOnly) {
- var builder = new StringBuilder();
-
- if (leftKey.equals(rightKey)) {
- if (!diffsOnly) {
- builder.append("left key ");
- builder.append(leftKey);
- builder.append(" equals right key ");
- builder.append(rightKey);
- builder.append('\n');
- }
- } else {
- builder.append("left key ");
- builder.append(leftKey);
- builder.append(" and right key ");
- builder.append(rightKey);
- builder.append(" differ\n");
- }
-
- return builder.toString();
- }
-}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java
deleted file mode 100644
index 9943690fa..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * ============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 java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Compare two maps and returns their differences. The types of the keys and the values in the two maps being comapred
- * must be the same. The class returns entries that are only in the left map, only in the right map, entries that have
- * identical keys and different values and entries that have different keys and different values in a
- * {@link KeyedMapDifference} instance.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <K> the type of the keys in the maps being compared
- * @param <V> the type of the values in the maps being compared
- */
-public class KeyedMapComparer<K, V> {
- /**
- * Compare two maps and return their differences in a {@link KeyedMapDifference} instance.
- *
- * @param leftMap The left map to be compared
- * @param rightMap The right map to be compared
- * @return The common, left only, and right only maps in a {@link KeyedMapDifference} instance
- */
- public KeyedMapDifference<K, V> compareMaps(final Map<K, V> leftMap, final Map<K, V> rightMap) {
- KeyedMapDifference<K, V> result = new KeyedMapDifference<>();
-
- // Get the keys that are only in the left map
- Set<K> leftOnlyKeys = new TreeSet<>(leftMap.keySet());
- leftOnlyKeys.removeAll(rightMap.keySet());
-
- // Get the keys that are only in the right map
- Set<K> rightOnlyKeys = new TreeSet<>(rightMap.keySet());
- rightOnlyKeys.removeAll(leftMap.keySet());
-
- // Find the keys common across both maps
- Set<K> commonKeys = new TreeSet<>(rightMap.keySet());
- commonKeys.addAll(leftMap.keySet());
- commonKeys.removeAll(leftOnlyKeys);
- commonKeys.removeAll(rightOnlyKeys);
-
- // Now save the left values
- for (K key : leftOnlyKeys) {
- result.getLeftOnly().put(key, leftMap.get(key));
- }
-
- // Now save the right values
- for (K key : rightOnlyKeys) {
- result.getRightOnly().put(key, rightMap.get(key));
- }
-
- // Save the common values to two maps, an identical and different map
- for (K key : commonKeys) {
- // Check if the values are identical in each map
- var leftValue = leftMap.get(key);
- var rightValue = rightMap.get(key);
-
- // Store as appropriate
- if (leftValue.equals(rightValue)) {
- result.getIdenticalValues().put(key, leftValue);
- } else {
- // Store the two values
- List<V> valueList = new ArrayList<>();
- valueList.add(leftValue);
- valueList.add(rightValue);
-
- result.getDifferentValues().put(key, valueList);
- }
- }
-
- return result;
- }
-}
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
deleted file mode 100644
index e10854926..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * ============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 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
- * {@code leftOnly} result is the entries that appear only in the left map. the {@code rightOnly} result is the entries
- * that appear only in the right map. The {@code differentValues} result are the entries that have the same key but
- * different values in the maps being compared. The {@code identicalValues} result are the entries with identical keys
- * and values in both maps being compared.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @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=";
-
- // Three maps to hold the comparison result
- private Map<K, V> leftOnly = new TreeMap<>();
- private Map<K, V> rightOnly = new TreeMap<>();
- private Map<K, V> identicalValues = new TreeMap<>();
- private Map<K, List<V>> differentValues = new TreeMap<>();
-
- /**
- * Return a string representation of the differences.
- *
- * @param diffsOnly if set, then a blank string is returned if the maps are equal
- * @param keysOnly if set, then a terse string that prints only the keys is returned, otherwise both keys and values
- * are printed
- * @return the string
- */
- public String asString(final boolean diffsOnly, final boolean keysOnly) {
- var builder = new StringBuilder();
-
- if (leftOnly.isEmpty()) {
- if (!diffsOnly) {
- builder.append("*** all left keys in right\n");
- }
- } else {
- builder.append(getInOneSideOnlyAsString(leftOnly, "left", keysOnly));
- }
-
- if (rightOnly.isEmpty()) {
- if (!diffsOnly) {
- builder.append("*** all right keys in left\n");
- }
- } else {
- builder.append(getInOneSideOnlyAsString(rightOnly, "right", keysOnly));
- }
-
- if (differentValues.isEmpty()) {
- if (!diffsOnly) {
- builder.append("*** all values in left and right are identical\n");
- }
- } else {
- builder.append(getDifferencesAsString(keysOnly));
- }
-
- if (!diffsOnly) {
- builder.append(getIdenticalsAsString(keysOnly));
- }
-
- return builder.toString();
- }
-
- /**
- * 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
- * @return the entries as a string
- */
- private Object getInOneSideOnlyAsString(final Map<K, V> sideMap, final String sideMapString,
- final boolean keysOnly) {
- var builder = new StringBuilder();
-
- builder.append("*** list of keys on " + sideMapString + " only\n");
- for (Entry<K, V> leftEntry : sideMap.entrySet()) {
- builder.append(KEY);
- builder.append(leftEntry.getKey());
- if (!keysOnly) {
- builder.append(VALUE);
- builder.append(leftEntry.getValue());
- }
- builder.append('\n');
- }
-
- return builder.toString();
- }
-
- /**
- * 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
- */
- private String getDifferencesAsString(final boolean keysOnly) {
- var builder = new StringBuilder();
-
- builder.append("*** list of differing entries between left and right\n");
- for (Entry<K, List<V>> differentEntry : differentValues.entrySet()) {
- builder.append(KEY);
- builder.append(differentEntry.getKey());
- if (!keysOnly) {
- builder.append(",values={");
- var first = true;
- for (V differentEntryValue : differentEntry.getValue()) {
- builder.append(differentEntryValue);
- if (first) {
- first = false;
- } else {
- builder.append(',');
- }
- }
- builder.append("}");
- }
- builder.append('\n');
- }
-
- return builder.toString();
- }
-
- /**
- * 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
- */
- private String getIdenticalsAsString(final boolean keysOnly) {
- var builder = new StringBuilder();
-
- builder.append("*** list of identical entries in left and right\n");
- for (Entry<K, V> identicalEntry : identicalValues.entrySet()) {
- builder.append(KEY);
- builder.append(identicalEntry.getKey());
- if (!keysOnly) {
- builder.append(VALUE);
- builder.append(identicalEntry.getValue());
- }
- builder.append('\n');
- }
-
- return builder.toString();
- }
-}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/package-info.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/package-info.java
deleted file mode 100644
index f0488eacd..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-/**
- * Provides utility template classes that compare keys and maps of any type.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-package org.onap.policy.apex.model.utilities.comparison;
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
deleted file mode 100644
index 66e389fa2..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============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.json;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-/**
- * This class reads objects of the given class from an input stream.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @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.
- *
- * @param inputClass The class to read
- * @param inputStream the input stream to read from
- * @return the object read
- */
- public P read(final Class<P> inputClass, final InputStream inputStream) {
- final Reader jsonResourceReader = new InputStreamReader(inputStream);
- return GSON.fromJson(jsonResourceReader, inputClass);
- }
-}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/package-info.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/package-info.java
deleted file mode 100755
index f9d1304d7..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-/**
- * Provides a utility class for reading JSON streams.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-package org.onap.policy.apex.model.utilities.json;
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/package-info.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/package-info.java
deleted file mode 100644
index 446d009ba..000000000
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-/**
- * Provides utility classes that are used in APEX models and indeed in other packages that use APEX models.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-package org.onap.policy.apex.model.utilities;