Refactor models for common type handling
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / authorative / concepts / ToscaPolicy.java
index e861606..00d783d 100644 (file)
@@ -2,7 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Model
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * 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.
 
 package org.onap.policy.models.tosca.authorative.concepts;
 
-import java.util.LinkedHashMap;
-import java.util.Map;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import lombok.NonNull;
+import lombok.ToString;
 
 /**
  * Class to represent TOSCA policy matching input/output from/to client.
@@ -34,29 +35,16 @@ import lombok.NonNull;
  * @author Chenfei Gao (cgao@research.att.com)
  */
 @Data
+@EqualsAndHashCode(callSuper = true)
 @NoArgsConstructor
-public class ToscaPolicy {
-
-    private String type;
-
-    private String version;
-
-    private String description;
-
-    private Map<String, String> metadata;
-
-    private Map<String, Object> properties;
-
+@ToString(callSuper = true)
+public class ToscaPolicy extends ToscaWithTypeAndObjectProperties {
     /**
      * Copy constructor.
      *
-     * @param copyObject the obejct to copy from.
+     * @param copyObject object to copy
      */
     public ToscaPolicy(@NonNull ToscaPolicy copyObject) {
-        this.type = copyObject.type;
-        this.version = copyObject.version;
-        this.description = copyObject.description;
-        this.metadata = (metadata != null ? new LinkedHashMap<>(copyObject.metadata) : null);
-        this.properties = (properties != null ? new LinkedHashMap<>(copyObject.properties) : null);
+        super(copyObject);
     }
 }