aboutsummaryrefslogtreecommitdiffstats
path: root/model/basic-model/src/main/java
diff options
context:
space:
mode:
authorlapentafd <francesco.lapenta@est.tech>2021-06-08 13:20:41 +0100
committerlapentafd <francesco.lapenta@est.tech>2021-06-09 17:00:00 +0100
commitb72448e8d134c9c591dc70a0f566e6487212282b (patch)
treec1eab2e715a84eb261c39ac44cb1d8ba7cddbeb0 /model/basic-model/src/main/java
parent471f4036f96a11a1d4bf33d39f3e802c8fdb4aae (diff)
Fix Sonar Issues in apex-pdp-basic-model
Test refactoring and use of Local-Variable Type Inference Issue-ID: POLICY-3093 Change-Id: If19c9ec96ba440a58eff679f276e4b53a26ce1ab Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Diffstat (limited to 'model/basic-model/src/main/java')
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java16
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java12
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java10
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java8
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java8
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java18
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java3
8 files changed, 41 insertions, 40 deletions
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java
index 86c89c35e..1edbc9be9 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -235,7 +235,7 @@ public class AxArtifactKey extends AxKey {
}
final AxArtifactKey otherArtifactKey = (AxArtifactKey) otherKey;
- final Compatibility compatibility = this.getCompatibility(otherArtifactKey);
+ final var compatibility = this.getCompatibility(otherArtifactKey);
return !(compatibility == Compatibility.DIFFERENT || compatibility == Compatibility.MAJOR);
}
@@ -245,14 +245,14 @@ public class AxArtifactKey extends AxKey {
*/
@Override
public AxValidationResult validate(final AxValidationResult result) {
- final String nameValidationErrorMessage = Assertions.getStringParameterValidationMessage(NAME_TOKEN, name,
+ final var nameValidationErrorMessage = Assertions.getStringParameterValidationMessage(NAME_TOKEN, name,
NAME_REGEXP);
if (nameValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
"name invalid-" + nameValidationErrorMessage));
}
- final String versionValidationErrorMessage = Assertions.getStringParameterValidationMessage(VERSION_TOKEN,
+ final var versionValidationErrorMessage = Assertions.getStringParameterValidationMessage(VERSION_TOKEN,
version, VERSION_REGEXP);
if (versionValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
@@ -276,7 +276,7 @@ public class AxArtifactKey extends AxKey {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("name=");
@@ -309,8 +309,8 @@ public class AxArtifactKey extends AxKey {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + name.hashCode();
result = prime * result + version.hashCode();
return result;
@@ -360,4 +360,4 @@ public class AxArtifactKey extends AxKey {
}
return version.compareTo(other.version);
}
-} \ No newline at end of file
+}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java
index 175cded08..9c907da9c 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
Assertions.argumentNotNull(conceptKeyName, "conceptKeyName may not be null");
// The very fist key that could have this name
- final AxArtifactKey lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
+ final var lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
// Check if we found a key for our name
AxArtifactKey foundKey = conceptMap.ceilingKey(lowestArtifactKey);
@@ -117,7 +117,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
}
// The very fist key that could have this name
- final AxArtifactKey lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
+ final var lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
if (conceptKeyVersion != null) {
lowestArtifactKey.setVersion(conceptKeyVersion);
}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
index 4b84a403a..7e92faddf 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -233,7 +233,7 @@ public class AxKeyInfo extends AxConcept {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("artifactId=");
@@ -269,8 +269,8 @@ public class AxKeyInfo extends AxConcept {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + uuid.hashCode();
result = prime * result + description.hashCode();
@@ -336,14 +336,14 @@ public class AxKeyInfo extends AxConcept {
* @return the uuid
*/
public static UUID generateReproducibleUuid(final String seed) {
- Random random = sharedRandom;
+ var random = sharedRandom;
if (!StringUtils.isEmpty(seed)) {
/*
* This is not used for encryption/security, thus disabling sonar.
*/
random = new Random(seed.hashCode()); // NOSONAR
}
- final byte[] array = new byte[UUID_BYTE_LENGTH_16];
+ final var array = new byte[UUID_BYTE_LENGTH_16];
random.nextBytes(array);
return UUID.nameUUIDFromBytes(array);
}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java
index 2619d2eea..fe597bb08 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -151,7 +151,7 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey
final AxArtifactKey artifactKey = (AxArtifactKey) axKey;
keyInfoMap.computeIfAbsent(artifactKey, unusedKey -> {
- final AxKeyInfo keyInfo = new AxKeyInfo(artifactKey);
+ final var keyInfo = new AxKeyInfo(artifactKey);
// generate a reproducible UUID
keyInfo.setUuid(AxKeyInfo.generateReproducibleUuid(keyInfo.getId() + keyInfo.getDescription()));
return keyInfo;
@@ -290,7 +290,7 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("key=");
@@ -327,8 +327,8 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + keyInfoMap.hashCode();
return result;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java
index fe786469b..eb701e5b3 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -139,7 +139,7 @@ public class AxKeyUse extends AxKey {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("usedKey=");
@@ -174,8 +174,8 @@ public class AxKeyUse extends AxKey {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + usedKey.hashCode();
return result;
}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
index da6fb49c6..4898b6d76 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -372,7 +372,7 @@ public class AxModel extends AxConcept {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("key=");
@@ -405,8 +405,8 @@ public class AxModel extends AxConcept {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + keyInformation.hashCode();
return result;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
index 4b9d647a9..33e26ef69 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -205,7 +205,7 @@ public class AxReferenceKey extends AxKey {
* the key ID in a format that respects the KEY_ID_REGEXP
*/
public AxReferenceKey(final String id) {
- final String conditionedId = Assertions.validateStringParameter("id", id, REFERENCE_KEY_ID_REGEXP);
+ final var conditionedId = Assertions.validateStringParameter("id", id, REFERENCE_KEY_ID_REGEXP);
// Split on colon, if the id passes the regular expression test above
// it'll have just three colons separating the parent name,
@@ -415,28 +415,28 @@ public class AxReferenceKey extends AxKey {
*/
@Override
public AxValidationResult validate(final AxValidationResult result) {
- final String parentNameValidationErrorMessage = Assertions.getStringParameterValidationMessage(PARENT_KEY_NAME,
+ final var parentNameValidationErrorMessage = Assertions.getStringParameterValidationMessage(PARENT_KEY_NAME,
parentKeyName, NAME_REGEXP);
if (parentNameValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
"parentKeyName invalid-" + parentNameValidationErrorMessage));
}
- final String parentKeyVersionValidationErrorMessage = Assertions
+ final var parentKeyVersionValidationErrorMessage = Assertions
.getStringParameterValidationMessage(PARENT_KEY_VERSION, parentKeyVersion, VERSION_REGEXP);
if (parentKeyVersionValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
"parentKeyVersion invalid-" + parentKeyVersionValidationErrorMessage));
}
- final String parentLocalNameValidationErrorMessage = Assertions
+ final var parentLocalNameValidationErrorMessage = Assertions
.getStringParameterValidationMessage(PARENT_LOCAL_NAME, parentLocalName, LOCAL_NAME_REGEXP);
if (parentLocalNameValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
"parentLocalName invalid-" + parentLocalNameValidationErrorMessage));
}
- final String localNameValidationErrorMessage = Assertions.getStringParameterValidationMessage(LOCAL_NAME,
+ final var localNameValidationErrorMessage = Assertions.getStringParameterValidationMessage(LOCAL_NAME,
localName, LOCAL_NAME_REGEXP);
if (localNameValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
@@ -462,7 +462,7 @@ public class AxReferenceKey extends AxKey {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("parentKeyName=");
@@ -501,8 +501,8 @@ public class AxReferenceKey extends AxKey {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + parentKeyName.hashCode();
result = prime * result + parentKeyVersion.hashCode();
result = prime * result + parentLocalName.hashCode();
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java
index d8580be06..8515f5724 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +51,7 @@ public class AxReferenceKeyAdapter extends XmlAdapter<String, AxReferenceKey> im
*/
@Override
public final AxReferenceKey unmarshal(final String key) throws Exception {
- final AxReferenceKey axReferenceKey = new AxReferenceKey();
+ final var axReferenceKey = new AxReferenceKey();
axReferenceKey.setLocalName(key);
return axReferenceKey;
}