summaryrefslogtreecommitdiffstats
path: root/models-base/src
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2023-07-27 10:12:59 +0100
committeradheli.tavares <adheli.tavares@est.tech>2023-09-22 12:58:53 +0100
commit938005505883cf7a636a8840e20e3dc8a0ad9176 (patch)
treef2820c1f44c458e95e565943b04b697cb5c88c12 /models-base/src
parentd19537308cbdce440c1faf819eb586983d0a67c9 (diff)
Java 17 Upgrade
Issue-ID: POLICY-4669 Change-Id: I0157ae0ea7151658308c7e6d429098f16824c190 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'models-base/src')
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConcept.java6
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java53
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java12
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfKey.java4
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java16
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java6
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfModel.java49
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfModelException.java26
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfModelRuntimeException.java26
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfModelService.java12
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java103
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java17
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfSearchableKey.java10
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java18
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfUtils.java52
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfValidator.java11
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java12
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java14
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java4
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfValidatorTest.java19
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java6
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptKeySub.java4
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptSub.java6
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java13
24 files changed, 253 insertions, 246 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java b/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
index 8afcaa159..c8be88d22 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
package org.onap.policy.models.base;
+import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import lombok.AccessLevel;
@@ -29,11 +30,12 @@ import lombok.NonNull;
/**
* This class is the base class for all Policy Framework concept classes. It enforces implementation of abstract methods
- * and interfaces on all concepts that are sub-classes of this class.
+ * and interfaces on all concepts that are subclasses of this class.
*/
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class PfConcept extends Validated implements Serializable, Comparable<PfConcept> {
+ @Serial
private static final long serialVersionUID = -7434939557282697490L;
/**
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
index 5f38a395a..395a42ce9 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -23,6 +23,15 @@
package org.onap.policy.models.base;
import com.google.re2j.Pattern;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.EmbeddedId;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.ManyToMany;
+import jakarta.persistence.MappedSuperclass;
+import jakarta.persistence.Table;
+import jakarta.ws.rs.core.Response;
+import java.io.Serial;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -34,14 +43,6 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.function.Function;
-import javax.persistence.CascadeType;
-import javax.persistence.EmbeddedId;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.MappedSuperclass;
-import javax.persistence.Table;
-import javax.ws.rs.core.Response;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
@@ -61,7 +62,7 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey;
* Each concept entry is checked to ensure that its key and value are not null and that the key matches the key in the
* map value. Each concept entry is then validated individually.
*
- * @param C the concept being contained
+ * @param <C> the concept being contained
*/
//@formatter:on
@MappedSuperclass
@@ -70,7 +71,8 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey;
@EqualsAndHashCode(callSuper = false)
public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> extends PfConcept
- implements PfConceptGetter<C>, PfAuthorative<List<Map<String, A>>> {
+ implements PfConceptGetter<C>, PfAuthorative<List<Map<String, A>>> {
+ @Serial
private static final long serialVersionUID = -324211738823208318L;
private static final String VALUE_FIELD = "value";
@@ -115,9 +117,9 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
}
/**
- * This Constructor creates an concept container with all of its fields defined.
+ * This Constructor creates a concept container with all of its fields defined.
*
- * @param key the concept container key
+ * @param key the concept container key
* @param conceptMap the concepts to be stored in the concept container
*/
public PfConceptContainer(@NonNull final PfConceptKey key, @NonNull final Map<PfConceptKey, C> conceptMap) {
@@ -200,9 +202,9 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
}
incomingConceptEntry.getValue().setName(findConceptField(conceptKey, conceptKey.getName(),
- incomingConceptEntry.getValue(), PfNameVersion::getDefinedName));
+ incomingConceptEntry.getValue(), PfNameVersion::getDefinedName));
incomingConceptEntry.getValue().setVersion(findConceptField(conceptKey, conceptKey.getVersion(),
- incomingConceptEntry.getValue(), PfNameVersion::getDefinedVersion));
+ incomingConceptEntry.getValue(), PfNameVersion::getDefinedVersion));
var jpaConcept = getConceptNewInstance();
// This cast allows us to call the fromAuthorative method
@@ -219,7 +221,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
if (conceptMap.isEmpty()) {
throw new PfModelRuntimeException(Response.Status.BAD_REQUEST,
- "An incoming list of concepts must have at least one entry");
+ "An incoming list of concepts must have at least one entry");
}
}
@@ -286,10 +288,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
}
@Override
- public int compareTo(final PfConcept otherConcept) {
- if (otherConcept == null) {
- return -1;
- }
+ public int compareTo(@NonNull final PfConcept otherConcept) {
if (this == otherConcept) {
return 0;
}
@@ -297,8 +296,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
return getClass().getName().compareTo(otherConcept.getClass().getName());
}
- @SuppressWarnings("unchecked")
- final PfConceptContainer<C, A> other = (PfConceptContainer<C, A>) otherConcept;
+ @SuppressWarnings("unchecked") final PfConceptContainer<C, A> other = (PfConceptContainer<C, A>) otherConcept;
int retVal = key.compareTo(other.key);
if (retVal != 0) {
return retVal;
@@ -310,7 +308,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
/**
* Get all the concepts that match the given name and version.
*
- * @param conceptKeyName the name of the concept, if null, return all names
+ * @param conceptKeyName the name of the concept, if null, return all names
* @param conceptKeyVersion the version of the concept, if null, return all versions
* @return conceptKeyVersion
*/
@@ -374,16 +372,17 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
private C getConceptNewInstance() {
try {
String conceptClassName =
- ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0].getTypeName();
+ ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0].getTypeName();
return (C) Class.forName(conceptClassName).getDeclaredConstructor().newInstance();
} catch (Exception ex) {
throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
- "failed to instantiate instance of container concept class", ex);
+ "failed to instantiate instance of container concept class", ex);
}
}
private String findConceptField(final PfConceptKey conceptKey, final String keyFieldValue,
- final PfNameVersion concept, final Function<PfNameVersion, String> fieldGetterFunction) {
+ final PfNameVersion concept,
+ final Function<PfNameVersion, String> fieldGetterFunction) {
String conceptField = fieldGetterFunction.apply(concept);
@@ -391,7 +390,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
return keyFieldValue;
} else {
throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, "Key " + conceptKey.getId() + " field "
- + keyFieldValue + " does not match the value " + conceptField + " in the concept field");
+ + keyFieldValue + " does not match the value " + conceptField + " in the concept field");
}
}
} \ No newline at end of file
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
index 98b67819e..cda2bbf42 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
@@ -21,8 +21,9 @@
package org.onap.policy.models.base;
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
@@ -31,7 +32,7 @@ import org.onap.policy.common.parameters.annotations.Pattern;
import org.onap.policy.common.utils.validation.Assertions;
/**
- * An concept key uniquely identifies every first order entity in the system. Every first order concept in the system
+ * A concept key uniquely identifies every first order entity in the system. Every first order concept in the system
* must have an {@link PfConceptKey} to identify it. Concepts that are wholly contained in another concept are
* identified using a {@link PfReferenceKey} key.
*
@@ -43,6 +44,7 @@ import org.onap.policy.common.utils.validation.Assertions;
@EqualsAndHashCode(callSuper = false)
@ToString
public class PfConceptKey extends PfKeyImpl {
+ @Serial
private static final long serialVersionUID = 8932717618579392561L;
@Column(name = NAME_TOKEN, length = 120)
@@ -72,7 +74,7 @@ public class PfConceptKey extends PfKeyImpl {
/**
* Constructor to create a key with the specified name and version.
*
- * @param name the key name
+ * @param name the key name
* @param version the key version
*/
public PfConceptKey(final String name, final String version) {
@@ -101,7 +103,7 @@ public class PfConceptKey extends PfKeyImpl {
*
* @return a null concept key
*/
- public static final PfConceptKey getNullKey() {
+ public static PfConceptKey getNullKey() {
return new PfConceptKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION);
}
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
index 949598828..8ff171ee3 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
package org.onap.policy.models.base;
+import java.io.Serial;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.NonNull;
@@ -31,6 +32,7 @@ import lombok.NonNull;
*/
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class PfKey extends PfConcept {
+ @Serial
private static final long serialVersionUID = 6281159885962014041L;
/** Regular expression to specify the structure of key names. */
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java b/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
index 3309fe9da..105e6f7f8 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
package org.onap.policy.models.base;
+import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
@@ -34,6 +35,7 @@ import org.onap.policy.common.utils.validation.Assertions;
@Getter
@ToString
public abstract class PfKeyImpl extends PfKey {
+ @Serial
private static final long serialVersionUID = 8932717618579392561L;
public static final String NAME_TOKEN = "name";
@@ -134,10 +136,9 @@ public abstract class PfKeyImpl extends PfKey {
@Override
public PfKey.Compatibility getCompatibility(@NonNull final PfKey otherKey) {
- if (!(otherKey instanceof PfKeyImpl)) {
+ if (!(otherKey instanceof PfKeyImpl otherConceptKey)) {
return Compatibility.DIFFERENT;
}
- final PfKeyImpl otherConceptKey = (PfKeyImpl) otherKey;
if (this.equals(otherConceptKey)) {
return Compatibility.IDENTICAL;
@@ -164,10 +165,9 @@ public abstract class PfKeyImpl extends PfKey {
@Override
public boolean isCompatible(@NonNull final PfKey otherKey) {
- if (!(otherKey instanceof PfKeyImpl)) {
+ if (!(otherKey instanceof PfKeyImpl otherConceptKey)) {
return false;
}
- final PfKeyImpl otherConceptKey = (PfKeyImpl) otherKey;
final var compatibility = this.getCompatibility(otherConceptKey);
@@ -193,17 +193,17 @@ public abstract class PfKeyImpl extends PfKey {
// There must always be at least one element in each version
if (!thisVersionArray[0].equals(otherVersionArray[0])) {
- return Integer.valueOf(thisVersionArray[0]) > Integer.valueOf(otherVersionArray[0]);
+ return Integer.parseInt(thisVersionArray[0]) > Integer.parseInt(otherVersionArray[0]);
}
if (thisVersionArray.length >= 2 && otherVersionArray.length >= 2
&& !thisVersionArray[1].equals(otherVersionArray[1])) {
- return Integer.valueOf(thisVersionArray[1]) > Integer.valueOf(otherVersionArray[1]);
+ return Integer.parseInt(thisVersionArray[1]) > Integer.parseInt(otherVersionArray[1]);
}
if (thisVersionArray.length >= 3 && otherVersionArray.length >= 3
&& !thisVersionArray[2].equals(otherVersionArray[2])) {
- return Integer.valueOf(thisVersionArray[2]) > Integer.valueOf(otherVersionArray[2]);
+ return Integer.parseInt(thisVersionArray[2]) > Integer.parseInt(otherVersionArray[2]);
}
return false;
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java b/models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java
index b753bb14a..f9141cc27 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
package org.onap.policy.models.base;
+import java.io.Serial;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -41,6 +42,7 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey;
@EqualsAndHashCode(callSuper = false)
@ToString
public class PfKeyUse extends PfKey {
+ @Serial
private static final long serialVersionUID = 2007147220109881705L;
@VerifyKey
@@ -139,7 +141,7 @@ public class PfKeyUse extends PfKey {
}
@Override
- public int compareTo(final PfConcept otherObj) {
+ public int compareTo(@NonNull final PfConcept otherObj) {
Assertions.argumentNotNull(otherObj, "comparison object may not be null");
if (this == otherObj) {
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
index e7b79cadf..1caa6329e 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -22,11 +22,12 @@
package org.onap.policy.models.base;
+import jakarta.persistence.EmbeddedId;
+import jakarta.persistence.MappedSuperclass;
+import java.io.Serial;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
-import javax.persistence.EmbeddedId;
-import javax.persistence.MappedSuperclass;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
@@ -41,12 +42,12 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey;
* from this model so all models must have a key and have key information.
*
* <p>Validation checks that the model key is valid. It goes on to check for null keys and checks
- * each key for uniqueness in the model. A check is carried out to ensure that an {@link PfKeyInfo}
+ * each key for uniqueness in the model. A check is carried out to ensure that an {@link PfKey}
* instance exists for every {@link PfConceptKey} key. For each {@link PfReferenceKey} instance, a
- * check is made that its parent and local name are nut null and that a {@link PfKeyInfo} entry
+ * check is made that its parent and local name are not null and that a {@link PfKey} entry
* exists for its parent. Then a check is made that each used {@link PfConceptKey} and
* {@link PfReferenceKey} usage references a key that exists. Finally, a check is made to ensure
- * that an {@link PfConceptKey} instance exists for every {@link PfKeyInfo} instance.
+ * that an {@link PfConceptKey} instance exists for every {@link PfKey} instance.
*
* @param <C> the type of concept on which the interface is applied.
*/
@@ -57,6 +58,7 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey;
public abstract class PfModel extends PfConcept {
private static final String KEYS_TOKEN = "keys";
+ @Serial
private static final long serialVersionUID = -771659065637205430L;
@EmbeddedId
@@ -146,13 +148,13 @@ public abstract class PfModel extends PfConcept {
/**
* Check for consistent usage of an artifact key in the model.
*
- * @param artifactKey The artifact key to check
+ * @param artifactKey The artifact key to check
* @param artifactKeySet The set of artifact keys encountered so far, this key is appended to
- * the set
- * @param result where to add the results
+ * the set
+ * @param result where to add the results
*/
private void validateArtifactKeyInModel(final PfConceptKey artifactKey,
- final Set<PfConceptKey> artifactKeySet, final BeanValidationResult result) {
+ final Set<PfConceptKey> artifactKeySet, final BeanValidationResult result) {
validateKeyNotNull(result, KEYS_TOKEN, artifactKey);
@@ -161,7 +163,7 @@ public abstract class PfModel extends PfConcept {
// Null key name start check
if (artifactKey.getName().toUpperCase().startsWith(PfKey.NULL_KEY_NAME)) {
addResult(result2, "name of " + artifactKey.getId(), artifactKey.getName(),
- "starts with keyword " + PfKey.NULL_KEY_NAME);
+ "starts with keyword " + PfKey.NULL_KEY_NAME);
}
// Unique key check
@@ -175,13 +177,14 @@ public abstract class PfModel extends PfConcept {
/**
* Check for consistent usage of a reference key in the model.
*
- * @param referenceKey The reference key to check
+ * @param referenceKey The reference key to check
* @param referenceKeySet The set of reference keys encountered so far, this key is appended to
- * the set
- * @param result where to add the results
+ * the set
+ * @param result where to add the results
*/
private void validateReferenceKeyInModel(final PfReferenceKey referenceKey,
- final Set<PfReferenceKey> referenceKeySet, final BeanValidationResult result) {
+ final Set<PfReferenceKey> referenceKeySet,
+ final BeanValidationResult result) {
// Null key check
if (referenceKey.isNullKey()) {
addResult(result, KEYS_TOKEN, referenceKey, IS_A_NULL_KEY);
@@ -192,7 +195,7 @@ public abstract class PfModel extends PfConcept {
// Null parent key check
if (referenceKey.getParentConceptKey().isNullKey()) {
addResult(result2, "parent key of " + referenceKey.getId(), referenceKey.getParentConceptKey().getId(),
- IS_A_NULL_KEY);
+ IS_A_NULL_KEY);
}
// Null local name check
@@ -203,7 +206,7 @@ public abstract class PfModel extends PfConcept {
// Null key name start check
if (referenceKey.getParentConceptKey().getName().toUpperCase().startsWith(PfKey.NULL_KEY_NAME)) {
addResult(result2, "parent name of " + referenceKey.getId(), referenceKey.getParentConceptKey().getName(),
- "starts with keyword " + PfKey.NULL_KEY_NAME);
+ "starts with keyword " + PfKey.NULL_KEY_NAME);
}
// Unique key check
@@ -217,15 +220,15 @@ public abstract class PfModel extends PfConcept {
/**
* Check for consistent usage of cross-key references in the model.
*
- * @param usedKeySet The set of all keys used in the model
- * @param artifactKeySet The set of artifact keys encountered so far, this key is appended to
- * the set
+ * @param usedKeySet The set of all keys used in the model
+ * @param artifactKeySet The set of artifact keys encountered so far, this key is appended to
+ * the set
* @param referenceKeySet The set of reference keys encountered so far, this key is appended to
- * the set
- * @param result where to add the results
+ * the set
+ * @param result where to add the results
*/
private void validateKeyUses(final Set<PfKeyUse> usedKeySet, final Set<PfConceptKey> artifactKeySet,
- final Set<PfReferenceKey> referenceKeySet, final BeanValidationResult result) {
+ final Set<PfReferenceKey> referenceKeySet, final BeanValidationResult result) {
// Check all key uses
for (final PfKeyUse usedKey : usedKeySet) {
if (usedKey.getKey() instanceof PfConceptKey) {
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModelException.java b/models-base/src/main/java/org/onap/policy/models/base/PfModelException.java
index c25fd17ec..9ffac0864 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfModelException.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfModelException.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,8 @@
package org.onap.policy.models.base;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
+import java.io.Serial;
import lombok.Getter;
import lombok.ToString;
import org.onap.policy.models.errors.concepts.ErrorResponse;
@@ -28,11 +29,12 @@ import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
import org.onap.policy.models.errors.concepts.ErrorResponseUtils;
/**
- * This class is a base exception from which all model exceptions are sub classes.
+ * This class is a base exception from which all model exceptions are subclasses.
*/
@Getter
@ToString
public class PfModelException extends Exception implements ErrorResponseInfo {
+ @Serial
private static final long serialVersionUID = -8507246953751956974L;
// The error response of the exception
@@ -45,7 +47,7 @@ public class PfModelException extends Exception implements ErrorResponseInfo {
* Instantiates a new model exception.
*
* @param statusCode the return code for the exception
- * @param message the message on the exception
+ * @param message the message on the exception
*/
public PfModelException(final Response.Status statusCode, final String message) {
this(statusCode, message, null);
@@ -55,8 +57,8 @@ public class PfModelException extends Exception implements ErrorResponseInfo {
* Instantiates a new model exception.
*
* @param statusCode the return code for the exception
- * @param message the message on the exception
- * @param object the object that the exception was thrown on
+ * @param message the message on the exception
+ * @param object the object that the exception was thrown on
*/
public PfModelException(final Response.Status statusCode, final String message, final Object object) {
super(message);
@@ -69,8 +71,8 @@ public class PfModelException extends Exception implements ErrorResponseInfo {
* Instantiates a new model exception.
*
* @param statusCode the return code for the exception
- * @param message the message on the exception
- * @param exception the exception that caused this exception
+ * @param message the message on the exception
+ * @param exception the exception that caused this exception
*/
public PfModelException(final Response.Status statusCode, final String message, final Exception exception) {
this(statusCode, message, exception, null);
@@ -80,12 +82,12 @@ public class PfModelException extends Exception implements ErrorResponseInfo {
* Instantiates a new exception.
*
* @param statusCode the return code for the exception
- * @param message the message on the exception
- * @param exception the exception that caused this exception
- * @param object the object that the exception was thrown on
+ * @param message the message on the exception
+ * @param exception the exception that caused this exception
+ * @param object the object that the exception was thrown on
*/
public PfModelException(final Response.Status statusCode, final String message, final Exception exception,
- final Object object) {
+ final Object object) {
super(message, exception);
errorResponse.setResponseCode(statusCode);
ErrorResponseUtils.getExceptionMessages(errorResponse, this);
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModelRuntimeException.java b/models-base/src/main/java/org/onap/policy/models/base/PfModelRuntimeException.java
index cd0562f90..44e9db950 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfModelRuntimeException.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfModelRuntimeException.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019, 2021 Nordix Foundation.
+ * Copyright (C) 2019, 2021, 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,8 @@
package org.onap.policy.models.base;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
+import java.io.Serial;
import lombok.Getter;
import lombok.ToString;
import org.onap.policy.models.errors.concepts.ErrorResponse;
@@ -28,11 +29,12 @@ import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
import org.onap.policy.models.errors.concepts.ErrorResponseUtils;
/**
- * This class is a base model run time exception from which all model run time exceptions are sub classes.
+ * This class is a base model run time exception from which all model run time exceptions are subclasses.
*/
@Getter
@ToString
public class PfModelRuntimeException extends RuntimeException implements ErrorResponseInfo {
+ @Serial
private static final long serialVersionUID = -8507246953751956974L;
// The error response of the exception
@@ -45,7 +47,7 @@ public class PfModelRuntimeException extends RuntimeException implements ErrorRe
* Instantiates a new model runtime exception.
*
* @param statusCode the return code for the exception
- * @param message the message on the exception
+ * @param message the message on the exception
*/
public PfModelRuntimeException(final Response.Status statusCode, final String message) {
this(statusCode, message, null);
@@ -55,8 +57,8 @@ public class PfModelRuntimeException extends RuntimeException implements ErrorRe
* Instantiates a new model runtime exception.
*
* @param statusCode the return code for the exception
- * @param message the message on the exception
- * @param object the object that the exception was thrown on
+ * @param message the message on the exception
+ * @param object the object that the exception was thrown on
*/
public PfModelRuntimeException(final Response.Status statusCode, final String message, final Object object) {
super(message);
@@ -69,8 +71,8 @@ public class PfModelRuntimeException extends RuntimeException implements ErrorRe
* Instantiates a new model runtime exception.
*
* @param statusCode the return code for the exception
- * @param message the message on the exception
- * @param exception the exception that caused this model exception
+ * @param message the message on the exception
+ * @param exception the exception that caused this model exception
*/
public PfModelRuntimeException(final Response.Status statusCode, final String message, final Exception exception) {
this(statusCode, message, exception, null);
@@ -92,12 +94,12 @@ public class PfModelRuntimeException extends RuntimeException implements ErrorRe
* Instantiates a new model runtime exception.
*
* @param statusCode the return code for the exception
- * @param message the message on the exception
- * @param exception the exception that caused this model exception
- * @param object the object that the exception was thrown on
+ * @param message the message on the exception
+ * @param exception the exception that caused this model exception
+ * @param object the object that the exception was thrown on
*/
public PfModelRuntimeException(final Response.Status statusCode, final String message, final Exception exception,
- final Object object) {
+ final Object object) {
super(message, exception);
this.object = object;
errorResponse.setResponseCode(statusCode);
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java b/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
index 860288b8e..94a7c0eac 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
@@ -21,9 +21,9 @@
package org.onap.policy.models.base;
+import jakarta.ws.rs.core.Response;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import javax.ws.rs.core.Response;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.NonNull;
@@ -42,14 +42,14 @@ import lombok.NonNull;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class PfModelService {
// The map holding the models
- private static Map<String, PfConcept> modelMap = new ConcurrentHashMap<>();
+ private static final Map<String, PfConcept> modelMap = new ConcurrentHashMap<>();
/**
* Register a model with the model service.
*
- * @param <M> the generic type
+ * @param <M> the generic type
* @param modelKey the key of the model, used to index the model
- * @param model The model
+ * @param model The model
*/
public static <M extends PfConcept> void registerModel(@NonNull final String modelKey, @NonNull final M model) {
modelMap.put(modelKey, model);
@@ -67,7 +67,7 @@ public final class PfModelService {
/**
* Get a model from the model service.
*
- * @param <M> the generic type
+ * @param <M> the generic type
* @param modelKey the key of the model, used to index the model
* @return The model
*/
@@ -77,7 +77,7 @@ public final class PfModelService {
if (model == null) {
throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
- "Model for name " + modelKey + " not found in model service");
+ "Model for name " + modelKey + " not found in model service");
}
return model;
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java
index acbebf959..246f8f069 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019,2021 Nordix Foundation.
+ * Copyright (C) 2019, 2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,10 +21,11 @@
package org.onap.policy.models.base;
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
@@ -58,14 +59,19 @@ public class PfReferenceKey extends PfKey {
private static final String PARENT_LOCAL_NAME = "parentLocalName";
private static final String LOCAL_NAME = "localName";
+ @Serial
private static final long serialVersionUID = 8932717618579392561L;
- /** Regular expression to specify the structure of local names in reference keys. */
+ /**
+ * Regular expression to specify the structure of local names in reference keys.
+ */
public static final String LOCAL_NAME_REGEXP = "[A-Za-z0-9\\-_\\.]+|^$";
- /** Regular expression to specify the structure of IDs in reference keys. */
+ /**
+ * Regular expression to specify the structure of IDs in reference keys.
+ */
public static final String REFERENCE_KEY_ID_REGEXP =
- "[A-Za-z0-9\\-_]+:[0-9].[0-9].[0-9]:[A-Za-z0-9\\-_]+:[A-Za-z0-9\\-_]+";
+ "[A-Za-z0-9\\-_]+:[0-9].[0-9].[0-9]:[A-Za-z0-9\\-_]+:[A-Za-z0-9\\-_]+";
private static final int PARENT_NAME_FIELD = 0;
private static final int PARENT_VERSION_FIELD = 1;
@@ -102,19 +108,17 @@ public class PfReferenceKey extends PfKey {
/**
* The Copy Constructor creates a key by copying another key.
*
- * @param referenceKey
- * the reference key to copy from
+ * @param referenceKey the reference key to copy from
*/
public PfReferenceKey(final PfReferenceKey referenceKey) {
this(referenceKey.getParentKeyName(), referenceKey.getParentKeyVersion(), referenceKey.getParentLocalName(),
- referenceKey.getLocalName());
+ referenceKey.getLocalName());
}
/**
* Constructor to create a null reference key for the specified parent concept key.
*
- * @param pfConceptKey
- * the parent concept key of this reference key
+ * @param pfConceptKey the parent concept key of this reference key
*/
public PfReferenceKey(final PfConceptKey pfConceptKey) {
this(pfConceptKey.getName(), pfConceptKey.getVersion(), NULL_KEY_NAME, NULL_KEY_NAME);
@@ -123,10 +127,8 @@ public class PfReferenceKey extends PfKey {
/**
* Constructor to create a reference key for the given parent concept key with the given local name.
*
- * @param pfConceptKey
- * the parent concept key of this reference key
- * @param localName
- * the local name of this reference key
+ * @param pfConceptKey the parent concept key of this reference key
+ * @param localName the local name of this reference key
*/
public PfReferenceKey(final PfConceptKey pfConceptKey, final String localName) {
this(pfConceptKey, NULL_KEY_NAME, localName);
@@ -135,10 +137,8 @@ public class PfReferenceKey extends PfKey {
/**
* Constructor to create a reference key for the given parent reference key with the given local name.
*
- * @param parentReferenceKey
- * the parent reference key of this reference key
- * @param localName
- * the local name of this reference key
+ * @param parentReferenceKey the parent reference key of this reference key
+ * @param localName the local name of this reference key
*/
public PfReferenceKey(final PfReferenceKey parentReferenceKey, final String localName) {
this(parentReferenceKey.getParentConceptKey(), parentReferenceKey.getLocalName(), localName);
@@ -148,12 +148,9 @@ public class PfReferenceKey extends PfKey {
* Constructor to create a reference key for the given parent reference key (specified by the parent reference key's
* concept key and local name) with the given local name.
*
- * @param pfConceptKey
- * the concept key of the parent reference key of this reference key
- * @param parentLocalName
- * the local name of the parent reference key of this reference key
- * @param localName
- * the local name of this reference key
+ * @param pfConceptKey the concept key of the parent reference key of this reference key
+ * @param parentLocalName the local name of the parent reference key of this reference key
+ * @param localName the local name of this reference key
*/
public PfReferenceKey(final PfConceptKey pfConceptKey, final String parentLocalName, final String localName) {
this(pfConceptKey.getName(), pfConceptKey.getVersion(), parentLocalName, localName);
@@ -163,12 +160,9 @@ public class PfReferenceKey extends PfKey {
* Constructor to create a reference key for the given parent concept key (specified by the parent concept key's
* name and version) with the given local name.
*
- * @param parentKeyName
- * the name of the parent concept key of this reference key
- * @param parentKeyVersion
- * the version of the parent concept key of this reference key
- * @param localName
- * the local name of this reference key
+ * @param parentKeyName the name of the parent concept key of this reference key
+ * @param parentKeyVersion the version of the parent concept key of this reference key
+ * @param localName the local name of this reference key
*/
public PfReferenceKey(final String parentKeyName, final String parentKeyVersion, final String localName) {
this(parentKeyName, parentKeyVersion, NULL_KEY_NAME, localName);
@@ -178,31 +172,26 @@ public class PfReferenceKey extends PfKey {
* Constructor to create a reference key for the given parent key (specified by the parent key's name, version nad
* local name) with the given local name.
*
- * @param parentKeyName
- * the parent key name of this reference key
- * @param parentKeyVersion
- * the parent key version of this reference key
- * @param parentLocalName
- * the parent local name of this reference key
- * @param localName
- * the local name of this reference key
+ * @param parentKeyName the parent key name of this reference key
+ * @param parentKeyVersion the parent key version of this reference key
+ * @param parentLocalName the parent local name of this reference key
+ * @param localName the local name of this reference key
*/
public PfReferenceKey(final String parentKeyName, final String parentKeyVersion, final String parentLocalName,
- final String localName) {
+ final String localName) {
super();
this.parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, parentKeyName, NAME_REGEXP);
this.parentKeyVersion = Assertions.validateStringParameter(PARENT_KEY_VERSION, parentKeyVersion,
- VERSION_REGEXP);
+ VERSION_REGEXP);
this.parentLocalName = Assertions.validateStringParameter(PARENT_LOCAL_NAME, parentLocalName,
- LOCAL_NAME_REGEXP);
+ LOCAL_NAME_REGEXP);
this.localName = Assertions.validateStringParameter(LOCAL_NAME, localName, LOCAL_NAME_REGEXP);
}
/**
* Constructor to create a key from the specified key ID.
*
- * @param id
- * the key ID in a format that respects the KEY_ID_REGEXP
+ * @param id the key ID in a format that respects the KEY_ID_REGEXP
*/
public PfReferenceKey(final String id) {
final var conditionedId = Assertions.validateStringParameter("id", id, REFERENCE_KEY_ID_REGEXP);
@@ -215,13 +204,13 @@ public class PfReferenceKey extends PfKey {
// Initiate the new key
parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, nameVersionNameArray[PARENT_NAME_FIELD],
- NAME_REGEXP);
+ NAME_REGEXP);
parentKeyVersion = Assertions.validateStringParameter(PARENT_KEY_VERSION,
- nameVersionNameArray[PARENT_VERSION_FIELD], VERSION_REGEXP);
+ nameVersionNameArray[PARENT_VERSION_FIELD], VERSION_REGEXP);
parentLocalName = Assertions.validateStringParameter(PARENT_LOCAL_NAME,
- nameVersionNameArray[PARENT_LOCAL_NAME_FIELD], LOCAL_NAME_REGEXP);
+ nameVersionNameArray[PARENT_LOCAL_NAME_FIELD], LOCAL_NAME_REGEXP);
localName = Assertions.validateStringParameter(LOCAL_NAME, nameVersionNameArray[LOCAL_NAME_FIELD],
- LOCAL_NAME_REGEXP);
+ LOCAL_NAME_REGEXP);
}
/**
@@ -231,7 +220,7 @@ public class PfReferenceKey extends PfKey {
*/
public static PfReferenceKey getNullKey() {
return new PfReferenceKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION, PfKey.NULL_KEY_NAME,
- PfKey.NULL_KEY_NAME);
+ PfKey.NULL_KEY_NAME);
}
@Override
@@ -279,8 +268,7 @@ public class PfReferenceKey extends PfKey {
/**
* Sets the parent concept key of this reference key.
*
- * @param parentKey
- * the parent concept key of this reference key
+ * @param parentKey the parent concept key of this reference key
*/
public void setParentConceptKey(final PfConceptKey parentKey) {
Assertions.argumentNotNull(parentKey, "parentKey may not be null");
@@ -293,8 +281,7 @@ public class PfReferenceKey extends PfKey {
/**
* Sets the parent reference key of this reference key.
*
- * @param parentKey
- * the parent reference key of this reference key
+ * @param parentKey the parent reference key of this reference key
*/
public void setParentReferenceKey(final PfReferenceKey parentKey) {
Assertions.argumentNotNull(parentKey, "parentKey may not be null");
@@ -305,21 +292,19 @@ public class PfReferenceKey extends PfKey {
}
@Override
- public PfKey.Compatibility getCompatibility(final PfKey otherKey) {
- if (!(otherKey instanceof PfReferenceKey)) {
+ public PfKey.Compatibility getCompatibility(@NonNull final PfKey otherKey) {
+ if (!(otherKey instanceof PfReferenceKey otherReferenceKey)) {
return Compatibility.DIFFERENT;
}
- final PfReferenceKey otherReferenceKey = (PfReferenceKey) otherKey;
return this.getParentConceptKey().getCompatibility(otherReferenceKey.getParentConceptKey());
}
@Override
public boolean isCompatible(@NonNull final PfKey otherKey) {
- if (!(otherKey instanceof PfReferenceKey)) {
+ if (!(otherKey instanceof PfReferenceKey otherReferenceKey)) {
return false;
}
- final PfReferenceKey otherReferenceKey = (PfReferenceKey) otherKey;
return this.getParentConceptKey().isCompatible(otherReferenceKey.getParentConceptKey());
}
@@ -358,7 +343,7 @@ public class PfReferenceKey extends PfKey {
}
@Override
- public int compareTo(final PfConcept otherObj) {
+ public int compareTo(@NonNull final PfConcept otherObj) {
Assertions.argumentNotNull(otherObj, "comparison object may not be null");
if (this == otherObj) {
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java
index 8be1126af..c7838d8e3 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,15 +21,16 @@
package org.onap.policy.models.base;
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import jakarta.persistence.Embedded;
+import jakarta.persistence.Temporal;
+import jakarta.persistence.TemporalType;
+import java.io.Serial;
import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
-import javax.persistence.Embedded;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
@@ -46,6 +47,7 @@ import org.onap.policy.common.utils.validation.Assertions;
@Data
@EqualsAndHashCode(callSuper = false)
public class PfReferenceTimestampKey extends PfKey {
+ @Serial
private static final long serialVersionUID = 1130918285832617215L;
private static final String TIMESTAMP_TOKEN = "timeStamp";
@@ -298,10 +300,9 @@ public class PfReferenceTimestampKey extends PfKey {
@Override
public boolean isCompatible(@NonNull PfKey otherKey) {
- if (!(otherKey instanceof PfReferenceTimestampKey)) {
+ if (!(otherKey instanceof PfReferenceTimestampKey otherReferenceKey)) {
return false;
}
- final PfReferenceTimestampKey otherReferenceKey = (PfReferenceTimestampKey) otherKey;
return this.getReferenceKey().getParentConceptKey().isCompatible(otherReferenceKey.getReferenceKey()
.getParentConceptKey());
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfSearchableKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfSearchableKey.java
index 902d19869..2296953dc 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfSearchableKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfSearchableKey.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,8 +21,9 @@
package org.onap.policy.models.base;
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
@@ -37,6 +38,7 @@ import org.onap.policy.common.utils.validation.Assertions;
@Getter
@EqualsAndHashCode(callSuper = false)
public class PfSearchableKey extends PfKeyImpl {
+ @Serial
private static final long serialVersionUID = 8932717618579392561L;
/** Regular expression to specify the structure of key names. */
@@ -98,7 +100,7 @@ public class PfSearchableKey extends PfKeyImpl {
*
* @return a null key
*/
- public static final PfSearchableKey getNullKey() {
+ public static PfSearchableKey getNullKey() {
return new PfSearchableKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION);
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
index 1f5dc654a..ea12889e4 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Model
* ================================================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
+ * Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,12 +23,13 @@
package org.onap.policy.models.base;
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import jakarta.persistence.Temporal;
+import jakarta.persistence.TemporalType;
+import java.io.Serial;
import java.time.Instant;
import java.util.Date;
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
@@ -39,6 +40,7 @@ import org.onap.policy.common.utils.validation.Assertions;
@Data
@EqualsAndHashCode(callSuper = false)
public class PfTimestampKey extends PfKeyImpl {
+ @Serial
private static final long serialVersionUID = -8410208962541783805L;
private static final String TIMESTAMP_TOKEN = "timeStamp";
@@ -77,12 +79,12 @@ public class PfTimestampKey extends PfKeyImpl {
/**
* Constructor to create a key with the specified name and version.
*
- * @param name the key name
+ * @param name the key name
* @param version the key version
* @param instant the time stamp of key
*/
public PfTimestampKey(@NonNull final String name, @NonNull final String version,
- @NonNull final Instant instant) {
+ @NonNull final Instant instant) {
super(name, version);
this.timeStamp = Date.from(instant);
}
@@ -107,7 +109,7 @@ public class PfTimestampKey extends PfKeyImpl {
*
* @return a null key
*/
- public static final PfTimestampKey getNullKey() {
+ public static PfTimestampKey getNullKey() {
return new PfTimestampKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION, Instant.EPOCH);
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java b/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java
index 6f93010bb..51054ee77 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
+ * Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
package org.onap.policy.models.base;
+import jakarta.ws.rs.core.Response;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -29,7 +30,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;
-import javax.ws.rs.core.Response;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
@@ -46,7 +46,7 @@ public final class PfUtils {
/**
* Compare two objects using their equals methods, nulls are allowed.
*
- * @param leftObject the first object
+ * @param leftObject the first object
* @param rightObject the second object
* @return a measure of the comparison
*/
@@ -73,7 +73,7 @@ public final class PfUtils {
/**
* Compare two collections of the same type, nulls are allowed.
*
- * @param leftCollection the first collection
+ * @param leftCollection the first collection
* @param rightCollection the second collection
* @return a measure of the comparison
*/
@@ -89,7 +89,7 @@ public final class PfUtils {
/**
* Compare two maps of the same type, nulls are allowed.
*
- * @param leftMap the first map
+ * @param leftMap the first map
* @param rightMap the second map
* @return a measure of the comparison
*/
@@ -102,12 +102,12 @@ public final class PfUtils {
}
/**
- * Convenience method to apply a mapping function to all of the elements of a list, generating a new list.
+ * Convenience method to apply a mapping function to all the elements of a list, generating a new list.
*
- * @param source list whose elements are to be mapped, or {@code null}
- * @param mapFunc mapping function
+ * @param source list whose elements are to be mapped, or {@code null}
+ * @param mapFunc mapping function
* @param defaultValue value to be returned if source is {@code null}
- * @return a new list, containing mappings of all of the items in the original list
+ * @return a new list, containing mappings of all the items in the original list
*/
public static <T, R> List<R> mapList(List<T> source, Function<T, R> mapFunc, List<R> defaultValue) {
if (source == null) {
@@ -118,27 +118,26 @@ public final class PfUtils {
}
/**
- * Convenience method to apply a mapping function to all of the elements of a list, generating a new list.
+ * Convenience method to apply a mapping function to all the elements of a list, generating a new list.
*
- * @param source list whose elements are to be mapped, or {@code null}
+ * @param source list whose elements are to be mapped, or {@code null}
* @param mapFunc mapping function
- * @return a new list, containing mappings of all of the items in the original list, or {@code null} if the source
- * is {@code null}
+ * @return a new list, containing mappings of all the items in the original list, or {@code null} if the source
+ * is {@code null}
*/
public static <T, R> List<R> mapList(List<T> source, Function<T, R> mapFunc) {
return mapList(source, mapFunc, null);
}
/**
- * Convenience method to apply a mapping function to all of the values of a map, generating a new map.
+ * Convenience method to apply a mapping function to all the values of a map, generating a new map.
*
- * @param source map whose values are to be mapped, or {@code null}
- * @param mapFunc mapping function
+ * @param source map whose values are to be mapped, or {@code null}
+ * @param mapFunc mapping function
* @param defaultValue value to be returned if source is {@code null}
- * @return a new map, containing mappings of all of the items in the original map
+ * @return a new map, containing mappings of all the items in the original map
*/
- public static <K, T, R> Map<K, R> mapMap(Map<K, T> source, Function<T, R> mapFunc,
- Map<K, R> defaultValue) {
+ public static <K, T, R> Map<K, R> mapMap(Map<K, T> source, Function<T, R> mapFunc, Map<K, R> defaultValue) {
if (source == null) {
return defaultValue;
}
@@ -152,12 +151,12 @@ public final class PfUtils {
}
/**
- * Convenience method to apply a mapping function to all of the values of a map, generating a new map.
+ * Convenience method to apply a mapping function to all the values of a map, generating a new map.
*
- * @param source map whose values are to be mapped, or {@code null}
+ * @param source map whose values are to be mapped, or {@code null}
* @param mapFunc mapping function
- * @return a new map, containing mappings of all of the items in the original map, or {@code null} if the source is
- * {@code null}
+ * @return a new map, containing mappings of all the items in the original map, or {@code null} if the source is
+ * {@code null}
*/
public static <K, T, R> Map<K, R> mapMap(Map<K, T> source, Function<T, R> mapFunc) {
return mapMap(source, mapFunc, null);
@@ -176,15 +175,14 @@ public final class PfUtils {
}
try {
- @SuppressWarnings("unchecked")
- Class<? extends T> clazz = (Class<? extends T>) source.getClass();
+ @SuppressWarnings("unchecked") Class<? extends T> clazz = (Class<? extends T>) source.getClass();
return clazz.getConstructor(clazz).newInstance(source);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException
- | RuntimeException e) {
+ | RuntimeException e) {
throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
- "error copying concept key class: " + source.getClass().getName(), e);
+ "error copying concept key class: " + source.getClass().getName(), e);
}
}
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java b/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java
index db7b9d63e..c2eb2b649 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,11 +49,10 @@ public class PfValidator extends BeanValidator {
* @return {@code true} if the next check should be performed, {@code false} otherwise
*/
public boolean verPfMin(BeanValidationResult result, String fieldName, PfMin annot, Object value) {
- if (!(value instanceof Number)) {
+ if (!(value instanceof Number num)) {
return true;
}
- Number num = (Number) value;
if (num.longValue() == annot.allowed()) {
// this value is always allowed
return true;
@@ -93,11 +93,10 @@ public class PfValidator extends BeanValidator {
* @return {@code true} if the next check should be performed, {@code false} otherwise
*/
public boolean verKey(BeanValidationResult result, String fieldName, VerifyKey annot, Object value) {
- if (!(value instanceof PfKey)) {
+ if (!(value instanceof PfKey pfkey)) {
return true;
}
- var pfkey = (PfKey) value;
if (annot.keyNotNull() && pfkey.isNullKey()) {
result.addResult(fieldName, xlate(pfkey), ValidationStatus.INVALID, Validated.IS_A_NULL_KEY);
return false;
@@ -107,14 +106,12 @@ public class PfValidator extends BeanValidator {
verCascade(result, fieldName, value);
}
- if (!(pfkey instanceof PfKeyImpl)) {
+ if (!(pfkey instanceof PfKeyImpl keyimpl)) {
return true;
}
var result2 = new BeanValidationResult(fieldName, value);
- PfKeyImpl keyimpl = (PfKeyImpl) pfkey;
-
if (annot.nameNotNull() && keyimpl.isNullName()) {
result2.addResult("name", pfkey.getName(), ValidationStatus.INVALID, Validated.IS_NULL);
}
diff --git a/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java b/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java
index 52d17e74f..b92aed487 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019, 2021 Nordix Foundation.
+ * Copyright (C) 2019, 2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,9 +24,9 @@ package org.onap.policy.models.base;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
import java.io.IOException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
import org.junit.Test;
import org.onap.policy.models.errors.concepts.ErrorResponse;
@@ -44,7 +44,7 @@ public class ExceptionsTest {
String key = "A String";
PfModelException ae =
- new PfModelException(Response.Status.OK, MESSAGE, new IOException("IO exception message"), key);
+ new PfModelException(Response.Status.OK, MESSAGE, new IOException("IO exception message"), key);
ErrorResponse errorResponse = ae.getErrorResponse();
assertEquals("Message\nIO exception message", String.join("\n", errorResponse.getErrorDetails()));
assertEquals(key, ae.getObject());
@@ -56,10 +56,10 @@ public class ExceptionsTest {
String rkey = "A String";
PfModelRuntimeException re = new PfModelRuntimeException(Response.Status.OK, "Runtime Message",
- new IOException("IO runtime exception message"), rkey);
+ new IOException("IO runtime exception message"), rkey);
errorResponse = re.getErrorResponse();
assertEquals("Runtime Message\nIO runtime exception message",
- String.join("\n", errorResponse.getErrorDetails()));
+ String.join("\n", errorResponse.getErrorDetails()));
assertEquals(key, re.getObject());
PfModelRuntimeException pfre = new PfModelRuntimeException(ae);
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
index f5c6e3a9b..c526b231a 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
+ * Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -65,18 +65,18 @@ public class PfConceptContainerTest {
container = new DummyPfConceptContainer(new PfConceptKey());
assertNotNull(container);
- container = new DummyPfConceptContainer(new PfConceptKey(), new TreeMap<PfConceptKey, DummyPfConcept>());
+ container = new DummyPfConceptContainer(new PfConceptKey(), new TreeMap<>());
assertNotNull(container);
- assertThatThrownBy(() -> new PfConceptContainer((PfConceptKey) null, null)).hasMessageMatching(KEY_IS_NULL);
+ assertThatThrownBy(() -> new PfConceptContainer(null, null)).hasMessageMatching(KEY_IS_NULL);
- assertThatThrownBy(() -> new DummyPfConceptContainer((PfConceptKey) null, null))
+ assertThatThrownBy(() -> new DummyPfConceptContainer(null, null))
.hasMessageMatching(KEY_IS_NULL);
assertThatThrownBy(() -> new DummyPfConceptContainer(new PfConceptKey(), null))
.hasMessageMatching("^conceptMap is marked .*on.*ull but is null$");
- assertThatThrownBy(() -> new DummyPfConceptContainer(null, new TreeMap<PfConceptKey, DummyPfConcept>()))
+ assertThatThrownBy(() -> new DummyPfConceptContainer(null, new TreeMap<>()))
.hasMessageMatching(KEY_IS_NULL);
}
@@ -117,8 +117,8 @@ public class PfConceptContainerTest {
assertThatThrownBy(() -> new DummyPfConceptContainer((DummyPfConceptContainer) null))
.isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> container.compareTo(null)).isInstanceOf(NullPointerException.class);
- assertNotEquals(0, container.compareTo(null));
assertEquals(0, container.compareTo(container));
assertNotEquals(0, container.compareTo(conceptKey));
@@ -271,7 +271,7 @@ public class PfConceptContainerTest {
}
@Test(expected = NullPointerException.class)
- public void testnullKey() {
+ public void testNullKey() {
PfConceptKey nullKey = null;
new DummyPfConceptContainer(nullKey);
}
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java
index 5cebf1e91..8b6202042 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020, 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
import org.junit.Test;
import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfValidatorTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfValidatorTest.java
index 812916e3c..ed8c138be 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfValidatorTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfValidatorTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +25,9 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import jakarta.validation.Valid;
+import java.io.Serial;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.validation.Valid;
import lombok.Getter;
import lombok.NonNull;
import org.junit.Before;
@@ -123,13 +125,13 @@ public class PfValidatorTest {
// null key
data.key = new PfConceptKey();
assertThat(validator.validateTop("", data).getResult())
- .contains(KEY_FIELD, "NULL:0.0.0", Validated.IS_A_NULL_KEY).doesNotContain("name", "version");
+ .contains(KEY_FIELD, "NULL:0.0.0", Validated.IS_A_NULL_KEY).doesNotContain("name", "version");
// invalid version - should invoke verCascade() which will invoke key.validate()
data.key = new StandardCoder().decode("{'name':'abc', 'version':'xyzzy'}".replace('\'', '"'),
- PfConceptKey.class);
+ PfConceptKey.class);
assertThat(validator.validateTop("", data).getResult())
- .contains(KEY_FIELD, "version", "xyzzy", "regular expression").doesNotContain("name");
+ .contains(KEY_FIELD, "version", "xyzzy", "regular expression").doesNotContain("name");
// not a PfKeyImpl - should not check individual fields
PfKey pfkey = mock(PfKey.class);
@@ -142,18 +144,18 @@ public class PfValidatorTest {
// null name
data.key = new PfConceptKey(PfKey.NULL_KEY_NAME, "2.3.4");
assertThat(validator.validateTop("", data).getResult()).contains(KEY_FIELD, "name", "null")
- .doesNotContain("version", "2.3.4");
+ .doesNotContain("version", "2.3.4");
// null version
data.key = new PfConceptKey(STRING_VALUE, PfKey.NULL_KEY_VERSION);
assertThat(validator.validateTop("", data).getResult()).contains(KEY_FIELD, "version", "null")
- .doesNotContain("name", STRING_VALUE);
+ .doesNotContain("name", STRING_VALUE);
// null name, invalid version - should get two messages
data.key = new StandardCoder().decode("{'name':'NULL', 'version':'xyzzy'}".replace('\'', '"'),
- PfConceptKey.class);
+ PfConceptKey.class);
assertThat(validator.validateTop("", data).getResult()).contains(KEY_FIELD, "name", "null", "version", "xyzzy",
- "regular expression");
+ "regular expression");
/*
* Tests with all flags set to "false" (i.e., no validations).
@@ -165,6 +167,7 @@ public class PfValidatorTest {
AtomicBoolean called = new AtomicBoolean();
data2.key = new PfConceptKey() {
+ @Serial
private static final long serialVersionUID = 1L;
@Override
diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java
index 548c26252..25a6cb7ba 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,8 +21,9 @@
package org.onap.policy.models.base.testconcepts;
+import jakarta.persistence.EmbeddedId;
+import java.io.Serial;
import java.util.List;
-import javax.persistence.EmbeddedId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
@@ -38,6 +39,7 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey;
@Data
@EqualsAndHashCode(callSuper = false)
public class DummyPfConcept extends PfConcept implements PfAuthorative<DummyAuthorativeConcept> {
+ @Serial
private static final long serialVersionUID = 1L;
@EmbeddedId
diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptKeySub.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptKeySub.java
index 8352697e6..b204895c6 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptKeySub.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptKeySub.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@
package org.onap.policy.models.base.testconcepts;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
import lombok.NonNull;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelRuntimeException;
diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptSub.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptSub.java
index 2c3fd189e..089773d5f 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptSub.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptSub.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,12 +20,14 @@
package org.onap.policy.models.base.testconcepts;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
+import java.io.Serial;
import lombok.NonNull;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelRuntimeException;
public class DummyPfConceptSub extends DummyPfConcept {
+ @Serial
private static final long serialVersionUID = 1L;
/**
diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java
index 015d1a950..594528be8 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@
package org.onap.policy.models.base.testconcepts;
-import java.util.Arrays;
+import java.io.Serial;
import java.util.List;
import lombok.NonNull;
import org.onap.policy.common.parameters.BeanValidationResult;
@@ -29,6 +29,7 @@ import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfKey;
public class DummyPfKey extends PfKey {
+ @Serial
private static final long serialVersionUID = 1L;
public DummyPfKey() {
@@ -40,7 +41,7 @@ public class DummyPfKey extends PfKey {
}
@Override
- public int compareTo(PfConcept arg0) {
+ public int compareTo(@NonNull PfConcept arg0) {
return 0;
}
@@ -55,12 +56,12 @@ public class DummyPfKey extends PfKey {
}
@Override
- public Compatibility getCompatibility(PfKey otherKey) {
+ public Compatibility getCompatibility(@NonNull PfKey otherKey) {
return null;
}
@Override
- public boolean isCompatible(PfKey otherKey) {
+ public boolean isCompatible(@NonNull PfKey otherKey) {
return false;
}
@@ -71,7 +72,7 @@ public class DummyPfKey extends PfKey {
@Override
public List<PfKey> getKeys() {
- return Arrays.asList(getKey());
+ return List.of(getKey());
}
@Override