Add extra authorative TOSCA concepts
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / authorative / concepts / ToscaPolicy.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Model
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019-2020 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  * SPDX-License-Identifier: Apache-2.0
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.policy.models.tosca.authorative.concepts;
25
26 import com.google.gson.annotations.SerializedName;
27 import io.swagger.annotations.ApiModelProperty;
28 import java.util.LinkedHashMap;
29 import java.util.Map;
30 import java.util.Map.Entry;
31 import lombok.Data;
32 import lombok.EqualsAndHashCode;
33 import lombok.NoArgsConstructor;
34 import lombok.NonNull;
35 import lombok.ToString;
36
37 /**
38  * Class to represent TOSCA policy matching input/output from/to client.
39  *
40  * @author Chenfei Gao (cgao@research.att.com)
41  */
42 @Data
43 @EqualsAndHashCode(callSuper = true)
44 @NoArgsConstructor
45 @ToString(callSuper = true)
46 public class ToscaPolicy extends ToscaEntity {
47     private String type;
48
49     @ApiModelProperty(name = "type_version")
50     @SerializedName("type_version")
51     private String typeVersion;
52
53     private Map<String, Object> properties;
54
55     /**
56      * Copy constructor.
57      *
58      * @param copyObject the obejct to copy from.
59      */
60     public ToscaPolicy(@NonNull ToscaPolicy copyObject) {
61         super(copyObject);
62
63         this.type = copyObject.type;
64         this.typeVersion = copyObject.typeVersion;
65
66         if (copyObject.properties != null) {
67             properties = new LinkedHashMap<>();
68             for (final Entry<String, Object> propertyEntry : copyObject.properties.entrySet()) {
69                 properties.put(propertyEntry.getKey(), propertyEntry.getValue());
70             }
71         }
72     }
73
74     /**
75      * Gets the identifier for this policy.
76      *
77      * @return this policy's identifier
78      */
79     public ToscaPolicyIdentifier getIdentifier() {
80         return new ToscaPolicyIdentifier(getName(), getVersion());
81     }
82
83     /**
84      * Gets the type identifier for this policy.
85      *
86      * @return this policy's type identifier
87      */
88     public ToscaPolicyTypeIdentifier getTypeIdentifier() {
89         return new ToscaPolicyTypeIdentifier(getType(), getTypeVersion());
90     }
91 }