Make filters on TOSCA entities generic
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / authorative / concepts / ToscaEntity.java
index 10d3b7a..98efd19 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Model
  * ================================================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * 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.
@@ -32,6 +32,7 @@ import javax.ws.rs.core.Response;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.NonNull;
+import org.onap.policy.models.base.PfKey;
 import org.onap.policy.models.base.PfModelRuntimeException;
 import org.onap.policy.models.base.PfNameVersion;
 
@@ -43,8 +44,8 @@ import org.onap.policy.models.base.PfNameVersion;
 @Data
 @NoArgsConstructor
 public class ToscaEntity implements PfNameVersion {
-    private String name;
-    private String version;
+    private String name = PfKey.NULL_KEY_NAME;
+    private String version = PfKey.NULL_KEY_VERSION;
 
     @ApiModelProperty(name = "derived_from")
     @SerializedName("derived_from")
@@ -81,6 +82,16 @@ public class ToscaEntity implements PfNameVersion {
         return new ToscaEntityKey(name, version);
     }
 
+    @Override
+    public String getDefinedName() {
+        return (PfKey.NULL_KEY_NAME.equals(name) ? null : name);
+    }
+
+    @Override
+    public String getDefinedVersion() {
+        return (PfKey.NULL_KEY_VERSION.equals(version) ? null : version);
+    }
+
     /**
      * Convert a list of maps of TOSCA entities into a regular map.
      *
@@ -130,4 +141,21 @@ public class ToscaEntity implements PfNameVersion {
         return entityMap;
     }
 
+    /**
+     * Method that should be specialised to return the type of the entity if the entity has a type.
+     *
+     * @return the type of the entity or null if it has no type
+     */
+    public String getType() {
+        return null;
+    }
+
+    /**
+     * Method that should be specialised to return the type version of the entity if the entity has a type.
+     *
+     * @return the type of the entity or null if it has no type
+     */
+    public String getTypeVersion() {
+        return null;
+    }
 }