Refactor models for common type handling
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / authorative / concepts / ToscaPolicy.java
index 284e39c..00d783d 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Model
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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.
@@ -23,9 +23,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,52 +38,13 @@ import lombok.ToString;
 @EqualsAndHashCode(callSuper = true)
 @NoArgsConstructor
 @ToString(callSuper = true)
-public class ToscaPolicy extends ToscaEntity implements Comparable<ToscaPolicy> {
-    private String type;
-
-    private String typeVersion;
-
-    private Map<String, Object> properties;
-
+public class ToscaPolicy extends ToscaWithTypeAndObjectProperties {
     /**
      * Copy constructor.
      *
-     * @param copyObject the obejct to copy from.
+     * @param copyObject object to copy
      */
     public ToscaPolicy(@NonNull ToscaPolicy copyObject) {
         super(copyObject);
-
-        this.type = copyObject.type;
-        this.typeVersion = copyObject.typeVersion;
-
-        if (copyObject.properties != null) {
-            properties = new LinkedHashMap<>();
-            for (final Entry<String, Object> propertyEntry : copyObject.properties.entrySet()) {
-                properties.put(propertyEntry.getKey(), propertyEntry.getValue());
-            }
-        }
-    }
-
-    /**
-     * 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);
     }
 }