summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java4
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java9
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java10
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java8
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java2
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java11
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java10
7 files changed, 32 insertions, 22 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 8ca6d153e..9636ea7ce 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
@@ -92,9 +92,9 @@ public final class CollectionUtils {
// Get the next objects
@SuppressWarnings("unchecked")
- final T leftObject = (T) leftIterator.next();
+ final var leftObject = (T) leftIterator.next();
@SuppressWarnings("unchecked")
- final T rightObject = (T) rightIterator.next();
+ final var rightObject = (T) rightIterator.next();
// Compare the objects
@SuppressWarnings("unchecked")
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
index 2d96a5954..21c417c4d 100644
--- 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
@@ -2,6 +2,7 @@
* ============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.
@@ -22,6 +23,8 @@
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;
@@ -54,8 +57,10 @@ final class DirectoryDeleteShutdownHook extends Thread {
if (tempDir.exists()) {
// Empty and delete the directory
DirectoryUtils.emptyDirectory(tempDir);
- if (!tempDir.delete()) {
- LOGGER.warn("Failed to delete directory {}", 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
index cc92d2a7f..b0e8332b1 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
@@ -23,6 +23,8 @@
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;
@@ -51,7 +53,7 @@ public final class DirectoryUtils {
try {
// Get the name of the temporary directory
final String tempDirName = System.getProperty("java.io.tmpdir") + "/" + nameprefix + System.nanoTime();
- final File tempDir = new File(tempDirName);
+ final var tempDir = new File(tempDirName);
// Delete the directory if it already exists
if (tempDir.exists()) {
@@ -95,8 +97,10 @@ public final class DirectoryUtils {
}
// Delete the directory entry
- if (!directoryFile.delete()) {
- LOGGER.warn("Failed to delete directory file {}", directoryFile);
+ try {
+ Files.delete(directoryFile.toPath());
+ } catch (IOException e) {
+ LOGGER.warn("Failed to delete directory file {}", directoryFile, e);
}
}
}
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 3f369c0e0..d8bb469cf 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
@@ -100,15 +100,15 @@ public final class TreeMapUtils {
Map.Entry<?, ?> leftEntry = (Entry<?, ?>) leftIt.next();
Map.Entry<?, ?> rightEntry = (Entry<?, ?>) rightIt.next();
- K leftKey = (K) leftEntry.getKey();
- K rightKey = (K) rightEntry.getKey();
+ var leftKey = (K) leftEntry.getKey();
+ var rightKey = (K) rightEntry.getKey();
int result = ((Comparable<K>) leftKey).compareTo(rightKey);
if (result != 0) {
return result;
}
- V leftValue = (V) leftEntry.getValue();
- V rightValue = (V) rightEntry.getValue();
+ var leftValue = (V) leftEntry.getValue();
+ var rightValue = (V) rightEntry.getValue();
result = ((Comparable<V>) leftValue).compareTo(rightValue);
if (result != 0) {
return result;
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 b01c83d59..a0395cf16 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
@@ -63,7 +63,7 @@ public class KeyDifference<K> {
* @return the difference between the keys as a string
*/
public String asString(final boolean diffsOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
if (leftKey.equals(rightKey)) {
if (!diffsOnly) {
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
index 24ff55263..9943690fa 100644
--- 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
@@ -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=========================================================
*/
@@ -74,8 +75,8 @@ public class KeyedMapComparer<K, V> {
// 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
- V leftValue = leftMap.get(key);
- V rightValue = rightMap.get(key);
+ var leftValue = leftMap.get(key);
+ var rightValue = rightMap.get(key);
// Store as appropriate
if (leftValue.equals(rightValue)) {
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 a070ec9ce..e10854926 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
@@ -58,7 +58,7 @@ public class KeyedMapDifference<K, V> {
* @return the string
*/
public String asString(final boolean diffsOnly, final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
if (leftOnly.isEmpty()) {
if (!diffsOnly) {
@@ -101,7 +101,7 @@ public class KeyedMapDifference<K, V> {
*/
private Object getInOneSideOnlyAsString(final Map<K, V> sideMap, final String sideMapString,
final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
builder.append("*** list of keys on " + sideMapString + " only\n");
for (Entry<K, V> leftEntry : sideMap.entrySet()) {
@@ -124,7 +124,7 @@ public class KeyedMapDifference<K, V> {
* @return the differences as a string
*/
private String getDifferencesAsString(final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
builder.append("*** list of differing entries between left and right\n");
for (Entry<K, List<V>> differentEntry : differentValues.entrySet()) {
@@ -132,7 +132,7 @@ public class KeyedMapDifference<K, V> {
builder.append(differentEntry.getKey());
if (!keysOnly) {
builder.append(",values={");
- boolean first = true;
+ var first = true;
for (V differentEntryValue : differentEntry.getValue()) {
builder.append(differentEntryValue);
if (first) {
@@ -156,7 +156,7 @@ public class KeyedMapDifference<K, V> {
* @return the identical entries as a string
*/
private String getIdenticalsAsString(final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
builder.append("*** list of identical entries in left and right\n");
for (Entry<K, V> identicalEntry : identicalValues.entrySet()) {