Merge "Complete filters for Database Fetches"
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / authorative / concepts / ToscaPolicy.java
index 9bd84e8..284e39c 100644 (file)
@@ -26,7 +26,6 @@ package org.onap.policy.models.tosca.authorative.concepts;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
@@ -41,8 +40,8 @@ import lombok.ToString;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @NoArgsConstructor
-@ToString
-public class ToscaPolicy extends ToscaEntity {
+@ToString(callSuper = true)
+public class ToscaPolicy extends ToscaEntity implements Comparable<ToscaPolicy> {
     private String type;
 
     private String typeVersion;
@@ -67,4 +66,27 @@ public class ToscaPolicy extends ToscaEntity {
             }
         }
     }
+
+    /**
+     * Gets the identifier for this policy.
+     *
+     * @return this policy's identifier
+     */
+    public ToscaPolicyIdentifier getIdentifier() {
+        return new ToscaPolicyIdentifier(getName(), getVersion());
+    }
+
+    /**
+     * Gets the type identifier for this policy.
+     *
+     * @return this policy's type identifier
+     */
+    public ToscaPolicyTypeIdentifier getTypeIdentifier() {
+        return new ToscaPolicyTypeIdentifier(getType(), getTypeVersion());
+    }
+
+    @Override
+    public int compareTo(final ToscaPolicy other) {
+        return compareNameVersion(this, other);
+    }
 }