aboutsummaryrefslogtreecommitdiffstats
path: root/model/context-model/src/main/java
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@ericsson.com>2018-05-30 09:48:40 +0100
committerwaqas.ikram <waqas.ikram@ericsson.com>2018-05-30 16:29:30 +0100
commit8bad2ad828fad2f5f99a9a291ca0f5c51b62e4ca (patch)
tree7b02ec8dd5dcda881b9133169a753fc6671e44bf /model/context-model/src/main/java
parent55d93a12cc5575c872724f48585304b5eec77fea (diff)
Fixing Sonar bugs and code smells
Change-Id: I661cd409d01320fe11a29b7ea72b9e8f70e72a6c Issue-ID: POLICY-856 Signed-off-by: waqas.ikram <waqas.ikram@ericsson.com>
Diffstat (limited to 'model/context-model/src/main/java')
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java67
1 files changed, 38 insertions, 29 deletions
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
index f9d34cef6..a6e2ad9ac 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
@@ -51,21 +51,22 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
import org.onap.policy.apex.model.utilities.Assertions;
/**
- * This class is a context album container and holds a map of the context albums for an entire Apex model. All Apex
- * models that use context albums must have an {@link AxContextAlbums} field. The {@link AxContextAlbums} class
- * implements the helper methods of the {@link AxConceptGetter} interface to allow {@link AxContextAlbum} instances to
- * be retrieved by calling methods directly on this class without referencing the contained map.
+ * This class is a context album container and holds a map of the context albums for an entire Apex
+ * model. All Apex models that use context albums must have an {@link AxContextAlbums} field. The
+ * {@link AxContextAlbums} class implements the helper methods of the {@link AxConceptGetter}
+ * interface to allow {@link AxContextAlbum} instances to be retrieved by calling methods directly
+ * on this class without referencing the contained map.
* <p>
- * Validation checks that the container key is not null. An observation is issued if no context albums are defined in
- * the container. If context albums do exist, they are checked to ensure that keys and values are not null and that the
- * map key matches the key in the map value for all album entries. Each context album entry is then validated
- * individually.
+ * Validation checks that the container key is not null. An observation is issued if no context
+ * albums are defined in the container. If context albums do exist, they are checked to ensure that
+ * keys and values are not null and that the map key matches the key in the map value for all album
+ * entries. Each context album entry is then validated individually.
*/
@Entity
@Table(name = "AxContextAlbums")
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxContextAlbums", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = { "key", "albums" })
+@XmlType(name = "AxContextAlbums", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = {"key", "albums"})
public final class AxContextAlbums extends AxConcept implements AxConceptGetter<AxContextAlbum> {
private static final long serialVersionUID = -4844259809024470975L;
@@ -83,8 +84,8 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
// @formatter:on
/**
- * The Default Constructor creates a {@link AxContextAlbums} object with a null artifact key and creates an empty
- * context album map.
+ * The Default Constructor creates a {@link AxContextAlbums} object with a null artifact key and
+ * creates an empty context album map.
*/
public AxContextAlbums() {
this(new AxArtifactKey());
@@ -100,8 +101,8 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
}
/**
- * The Key Constructor creates a {@link AxContextAlbums} object with the given artifact key and creates an empty
- * context album map.
+ * The Key Constructor creates a {@link AxContextAlbums} object with the given artifact key and
+ * creates an empty context album map.
*
* @param key the key of the context album container
*/
@@ -126,9 +127,10 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
}
/**
- * When a model is unmarshalled from disk or from the database, the context album map is returned as a raw hash map.
- * This method is called by JAXB after unmarshaling and is used to convert the hash map to a {@link NavigableMap} so
- * that it will work with the {@link AxConceptGetter} interface.
+ * When a model is unmarshalled from disk or from the database, the context album map is
+ * returned as a raw hash map. This method is called by JAXB after unmarshaling and is used to
+ * convert the hash map to a {@link NavigableMap} so that it will work with the
+ * {@link AxConceptGetter} interface.
*
* @param u the unmarshaler that is unmarshaling the model
* @param parent the parent object of this object in the unmarshaler
@@ -234,7 +236,8 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.
* basicmodel.concepts.AxValidationResult)
*/
@Override
@@ -260,13 +263,7 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
"value on context album entry " + contextAlbumEntry.getKey() + " may not be null"));
} else {
- if (!contextAlbumEntry.getKey().equals(contextAlbumEntry.getValue().getKey())) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on context album entry key " + contextAlbumEntry.getKey()
- + " does not equal context album value key "
- + contextAlbumEntry.getValue().getKey()));
- }
+ validateContextAlbumKey(result, contextAlbumEntry);
result = contextAlbumEntry.getValue().validate(result);
}
@@ -276,10 +273,20 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
return result;
}
+ private void validateContextAlbumKey(final AxValidationResult result,
+ final Entry<AxArtifactKey, AxContextAlbum> contextAlbumEntry) {
+ if (!contextAlbumEntry.getKey().equals(contextAlbumEntry.getValue().getKey())) {
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key on context album entry key " + contextAlbumEntry.getKey()
+ + " does not equal context album value key " + contextAlbumEntry.getValue().getKey()));
+ }
+ }
+
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.
* basicmodel.concepts.AxConcept)
*/
@Override
@@ -371,8 +378,8 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#get(org.onap.policy.apex.model.
- * basicmodel.concepts.AxArtifactKey)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#get(org.onap.policy.apex.
+ * model.basicmodel.concepts.AxArtifactKey)
*/
@Override
public AxContextAlbum get(final AxArtifactKey conceptKey) {
@@ -392,7 +399,8 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#get(java.lang.String, java.lang.String)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#get(java.lang.String,
+ * java.lang.String)
*/
@Override
public AxContextAlbum get(final String conceptKeyName, final String conceptKeyVersion) {
@@ -413,7 +421,8 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#getAll(java.lang.String, java.lang.String)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter#getAll(java.lang.String,
+ * java.lang.String)
*/
@Override
public Set<AxContextAlbum> getAll(final String conceptKeyName, final String conceptKeyVersion) {