/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.ArrayList;
import java.util.List;
-
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.apex.model.utilities.Assertions;
+import org.onap.policy.common.utils.validation.Assertions;
/**
* An artifact key uniquely identifies every first order entity in the system. Every first order concept in the system
* must have an {@link AxArtifactKey} to identify it. Concepts that are wholly contained in another concept are
* identified using a {@link AxReferenceKey} key.
- * <p>
- * Key validation checks that the name and version fields match the {@link NAME_REGEXP} and {@link VERSION_REGEXP}
+ *
+ * <p>Key validation checks that the name and version fields match the NAME_REGEXP and VERSION_REGEXP
* regular expressions respectively.
*/
@Embeddable
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "apexArtifactKey", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxArtifactKey", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = { "name", "version" })
+@XmlType(name = "AxArtifactKey", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
+ { "name", "version" })
public class AxArtifactKey extends AxKey {
private static final long serialVersionUID = 8932717618579392561L;
}
/**
- * Copy constructor
+ * Copy constructor.
*
- * @param copyConcept
- * the concept to copy from
+ * @param copyConcept the concept to copy from
*/
public AxArtifactKey(final AxArtifactKey copyConcept) {
super(copyConcept);
/**
* Constructor to create a key with the specified name and version.
*
- * @param name
- * the key name
- * @param version
- * the key version
+ * @param name the key name
+ * @param version the key version
*/
public AxArtifactKey(final String name, final String version) {
super();
/**
* Constructor to create a key using the key and version from the specified key ID.
*
- * @param id
- * the key ID in a format that respects the {@link KEY_ID_REGEXP}
+ * @param id the key ID in a format that respects the KEY_ID_REGEXP
*/
public AxArtifactKey(final String id) {
Assertions.argumentNotNull(id, "id may not be null");
return new AxArtifactKey(AxKey.NULL_KEY_NAME, AxKey.NULL_KEY_VERSION);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
+ /**
+ * {@inheritDoc}.
*/
@Override
public AxArtifactKey getKey() {
return this;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
+ /**
+ * {@inheritDoc}.
*/
@Override
public List<AxKey> getKeys() {
return keyList;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxKey#getID()
+ /**
+ * {@inheritDoc}.
*/
@Override
- public String getID() {
+ public String getId() {
return name + ':' + version;
}
/**
* Sets the key name.
*
- * @param name
- * the key name
+ * @param name the key name
*/
public void setName(final String name) {
this.name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP);
/**
* Sets the key version.
*
- * @param version
- * the key version
+ * @param version the key version
*/
public void setVersion(final String version) {
this.version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
}
- /*
- * (non-Javadoc)
+ /**
+ * Check if the key is IDENTICAL to a null key.
*
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxKey#getCompatibility(org.onap.policy.apex.model.basicmodel.
- * concepts.AxKey)
+ * @return true, if the key is IDENTICAL to a null key
+ */
+ public boolean isNullKey() {
+ return this.getCompatibility(AxArtifactKey.getNullKey()).equals(AxKey.Compatibility.IDENTICAL);
+ }
+
+
+ /**
+ * {@inheritDoc}.
*/
@Override
public AxKey.Compatibility getCompatibility(final AxKey otherKey) {
return Compatibility.PATCH;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxKey#isCompatible(org.onap.policy.apex.model.basicmodel.concepts.
- * AxKey)
+ /**
+ * {@inheritDoc}.
*/
@Override
public boolean isCompatible(final AxKey otherKey) {
return !(compatibility == Compatibility.DIFFERENT || compatibility == Compatibility.MAJOR);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
- * AxValidationResult)
+ /**
+ * {@inheritDoc}.
*/
@Override
public AxValidationResult validate(final AxValidationResult result) {
"name invalid-" + nameValidationErrorMessage));
}
- final String versionValidationErrorMessage = Assertions.getStringParameterValidationMessage(VERSION_TOKEN, version,
- VERSION_REGEXP);
+ final String versionValidationErrorMessage = Assertions.getStringParameterValidationMessage(VERSION_TOKEN,
+ version, VERSION_REGEXP);
if (versionValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
"version invalid-" + versionValidationErrorMessage));
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
+ /**
+ * {@inheritDoc}.
*/
@Override
public void clean() {
version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
+ /**
+ * {@inheritDoc}.
*/
@Override
public String toString() {
return builder.toString();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
- * AxConcept)
+ /**
+ * {@inheritDoc}.
*/
@Override
public AxConcept copyTo(final AxConcept target) {
return copyObject;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
+ /**
+ * {@inheritDoc}.
*/
@Override
public int hashCode() {
return result;
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
+ /**
+ * {@inheritDoc}.
*/
@Override
public boolean equals(final Object obj) {
return version.equals(other.version);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
+ /**
+ * {@inheritDoc}.
*/
@Override
public int compareTo(final AxConcept otherObj) {
}
return version.compareTo(other.version);
}
-}
+}
\ No newline at end of file