Add ApiModelProperty annotation to authorative models
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / authorative / concepts / ToscaEntity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Model
4  * ================================================================================
5  * Copyright (C) 2019 Nordix Foundation.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.models.tosca.authorative.concepts;
24
25 import com.google.gson.annotations.SerializedName;
26 import io.swagger.annotations.ApiModelProperty;
27 import java.util.LinkedHashMap;
28 import java.util.Map;
29 import java.util.Map.Entry;
30 import lombok.Data;
31 import lombok.NoArgsConstructor;
32 import lombok.NonNull;
33 import org.onap.policy.models.base.PfNameVersion;
34
35 /**
36  * Class to represent TOSCA data type matching input/output from/to client.
37  *
38  * @author Chenfei Gao (cgao@research.att.com)
39  */
40 @Data
41 @NoArgsConstructor
42 public class ToscaEntity implements PfNameVersion {
43     private String name;
44
45     private String version;
46
47     @ApiModelProperty(name = "derived_from")
48     @SerializedName("derived_from")
49     private String derivedFrom;
50
51     private Map<String, String> metadata;
52
53     private String description;
54
55     /**
56      * Copy COnstructor.
57      *
58      * @param copyObject object to copy from
59      */
60     public ToscaEntity(@NonNull ToscaEntity copyObject) {
61         this.name = copyObject.name;
62         this.version = copyObject.version;
63         this.derivedFrom = copyObject.derivedFrom;
64         this.description = copyObject.description;
65
66         if (copyObject.metadata != null) {
67             metadata = new LinkedHashMap<>();
68             for (final Entry<String, String> metadataEntry : copyObject.metadata.entrySet()) {
69                 metadata.put(metadataEntry.getKey(), metadataEntry.getValue());
70             }
71         }
72     }
73
74 }