Merge "Refactor to authorative TOSCA serializtion"
[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 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 java.util.LinkedHashMap;
27 import java.util.Map;
28 import java.util.Map.Entry;
29
30 import lombok.Data;
31 import lombok.EqualsAndHashCode;
32 import lombok.NoArgsConstructor;
33 import lombok.NonNull;
34 import lombok.ToString;
35
36 /**
37  * Class to represent TOSCA policy matching input/output from/to client.
38  *
39  * @author Chenfei Gao (cgao@research.att.com)
40  */
41 @Data
42 @EqualsAndHashCode(callSuper = true)
43 @NoArgsConstructor
44 @ToString
45 public class ToscaPolicy extends ToscaEntity {
46     private String type;
47
48     private String typeVersion;
49
50     private Map<String, Object> properties;
51
52     /**
53      * Copy constructor.
54      *
55      * @param copyObject the obejct to copy from.
56      */
57     public ToscaPolicy(@NonNull ToscaPolicy copyObject) {
58         super(copyObject);
59
60         this.type = copyObject.type;
61         this.typeVersion = copyObject.typeVersion;
62
63         if (copyObject.properties != null) {
64             properties = new LinkedHashMap<>();
65             for (final Entry<String, Object> propertyEntry : copyObject.properties.entrySet()) {
66                 properties.put(propertyEntry.getKey(), propertyEntry.getValue());
67             }
68         }
69     }
70 }