aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-01-16 09:11:48 +0000
committerliamfallon <liam.fallon@est.tech>2021-01-16 09:15:58 +0000
commitcc12166b729fba5ec91e00897af4803f0fe6889a (patch)
tree4e8fee3ab9aed37791c859d41bad1bed6f7930cd /models-tosca/src/main
parent5b577fd7cc40eaad1a1e5db2d43ef9ffe820e9a2 (diff)
Add PfKey translation to ToscaConceptIdentifier
Concenience constructor to create a TosaConceptIdentifier from a PfKey and a method to create a PfConceptKey from a ToscaConceptIdentifier. Issue-ID: POLICY-2971 Change-Id: I402b2e12cc11976cd7e98436eb46486c35fdaa31 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src/main')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java
index 36e460e83..ade1a28d4 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java
@@ -27,6 +27,8 @@ import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
/**
* Identifies a concept. Both the name and version must be non-null.
@@ -47,6 +49,11 @@ public class ToscaConceptIdentifier implements Comparable<ToscaConceptIdentifier
this.version = version;
}
+ public ToscaConceptIdentifier(@NonNull PfKey key) {
+ this.name = key.getName();
+ this.version = key.getVersion();
+ }
+
public ToscaConceptIdentifier(ToscaConceptIdentifier source) {
this.name = source.name;
this.version = source.version;
@@ -66,6 +73,15 @@ public class ToscaConceptIdentifier implements Comparable<ToscaConceptIdentifier
return result;
}
+ /**
+ * Create a PfConcceptKey from the TOSCA identifier.
+ *
+ * @return the key
+ */
+ public PfConceptKey asConceptKey() {
+ return new PfConceptKey(name, version);
+ }
+
@Override
public int compareTo(ToscaConceptIdentifier other) {
if (this == other) {