Code Review
/
policy
/
models.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Java 17 Upgrade
[policy/models.git]
/
models-base
/
src
/
main
/
java
/
org
/
onap
/
policy
/
models
/
base
/
PfModel.java
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
82b8f93
..
1caa632
100644
(file)
--- 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,7
+1,8
@@
/*-
* ============LICENSE_START=======================================================
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * 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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-21,19
+22,16
@@
package org.onap.policy.models.base;
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 java.util.List;
import java.util.Set;
import java.util.TreeSet;
-import javax.persistence.EmbeddedId;
-import javax.persistence.Entity;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.onap.policy.common.parameters.BeanValidationResult;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.utils.validation.Assertions;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.utils.validation.Assertions;
@@
-44,24
+42,23
@@
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
* 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 PfKey
Info
}
+ * 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
* instance exists for every {@link PfConceptKey} key. For each {@link PfReferenceKey} instance, a
- * check is made that its parent and local name are n
ut null and that a {@link PfKeyInfo
} entry
+ * check is made that its parent and local name are n
ot 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
* 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 PfKey
Info
} instance.
+ * that an {@link PfConceptKey} instance exists for every {@link PfKey} instance.
*
* @param <C> the type of concept on which the interface is applied.
*/
*
* @param <C> the type of concept on which the interface is applied.
*/
-@Entity
-@Table(name = "PfModel")
-@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@MappedSuperclass
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class PfModel extends PfConcept {
private static final String KEYS_TOKEN = "keys";
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class PfModel extends PfConcept {
private static final String KEYS_TOKEN = "keys";
+ @Serial
private static final long serialVersionUID = -771659065637205430L;
@EmbeddedId
private static final long serialVersionUID = -771659065637205430L;
@EmbeddedId
@@
-72,7
+69,7
@@
public abstract class PfModel extends PfConcept {
/**
* The Default Constructor creates this concept with a NULL artifact key.
*/
/**
* The Default Constructor creates this concept with a NULL artifact key.
*/
- p
ublic
PfModel() {
+ p
rotected
PfModel() {
this(new PfConceptKey());
}
this(new PfConceptKey());
}
@@
-81,7
+78,7
@@
public abstract class PfModel extends PfConcept {
*
* @param key the key of this concept
*/
*
* @param key the key of this concept
*/
- p
ublic
PfModel(@NonNull final PfConceptKey key) {
+ p
rotected
PfModel(@NonNull final PfConceptKey key) {
super();
Assertions.argumentNotNull(key, "key may not be null");
super();
Assertions.argumentNotNull(key, "key may not be null");
@@
-93,7
+90,7
@@
public abstract class PfModel extends PfConcept {
*
* @param copyConcept the concept to copy from
*/
*
* @param copyConcept the concept to copy from
*/
- p
ublic
PfModel(@NonNull final PfModel copyConcept) {
+ p
rotected
PfModel(@NonNull final PfModel copyConcept) {
super(copyConcept);
this.key = new PfConceptKey(copyConcept.key);
}
super(copyConcept);
this.key = new PfConceptKey(copyConcept.key);
}
@@
-151,22
+148,22
@@
public abstract class PfModel extends PfConcept {
/**
* Check for consistent usage of an artifact key in the model.
*
/**
* 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
* @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,
*/
private void validateArtifactKeyInModel(final PfConceptKey artifactKey,
- final Set<PfConceptKey> artifactKeySet, final BeanValidationResult result) {
+
final Set<PfConceptKey> artifactKeySet, final BeanValidationResult result) {
-
result.addResult(validateKeyNotNull(KEYS_TOKEN, artifactKey)
);
+
validateKeyNotNull(result, KEYS_TOKEN, artifactKey
);
-
BeanValidationResult
result2 = new BeanValidationResult(KEYS_TOKEN, artifactKey);
+
var
result2 = new BeanValidationResult(KEYS_TOKEN, artifactKey);
// Null key name start check
if (artifactKey.getName().toUpperCase().startsWith(PfKey.NULL_KEY_NAME)) {
addResult(result2, "name of " + artifactKey.getId(), artifactKey.getName(),
// 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
}
// Unique key check
@@
-180,24
+177,25
@@
public abstract class PfModel extends PfConcept {
/**
* Check for consistent usage of a reference key in the model.
*
/**
* 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
* @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,
*/
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);
}
// Null key check
if (referenceKey.isNullKey()) {
addResult(result, KEYS_TOKEN, referenceKey, IS_A_NULL_KEY);
}
-
BeanValidationResult
result2 = new BeanValidationResult(KEYS_TOKEN, referenceKey);
+
var
result2 = new BeanValidationResult(KEYS_TOKEN, referenceKey);
// Null parent key check
if (referenceKey.getParentConceptKey().isNullKey()) {
addResult(result2, "parent key of " + referenceKey.getId(), referenceKey.getParentConceptKey().getId(),
// 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
}
// Null local name check
@@
-208,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(),
// 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
}
// Unique key check
@@
-222,28
+220,26
@@
public abstract class PfModel extends PfConcept {
/**
* Check for consistent usage of cross-key references in the model.
*
/**
* 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
* @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,
*/
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) {
// PfConceptKey usage, check the key exists
if (!artifactKeySet.contains(usedKey.getKey())) {
// Check all key uses
for (final PfKeyUse usedKey : usedKeySet) {
if (usedKey.getKey() instanceof PfConceptKey) {
// PfConceptKey usage, check the key exists
if (!artifactKeySet.contains(usedKey.getKey())) {
- result.addResult(new ObjectValidationResult("artifact key", usedKey.getId(),
- ValidationStatus.INVALID, NOT_DEFINED));
+ result.addResult("artifact key", usedKey.getId(), ValidationStatus.INVALID, NOT_DEFINED);
}
} else {
// PfReferenceKey usage, check the key exists
if (!referenceKeySet.contains(usedKey.getKey())) {
}
} else {
// PfReferenceKey usage, check the key exists
if (!referenceKeySet.contains(usedKey.getKey())) {
- result.addResult(new ObjectValidationResult("reference key", usedKey.getId(),
- ValidationStatus.INVALID, NOT_DEFINED));
+ result.addResult("reference key", usedKey.getId(), ValidationStatus.INVALID, NOT_DEFINED);
}
}
}
}
}
}