Merge "Fix the tosca converter"
[clamp.git] / src / main / java / org / onap / clamp / clds / tosca / update / ToscaElement.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2020 AT&T Intellectual Property. All rights
6  *                             reserved.
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  * ============LICENSE_END============================================
20  * ===================================================================
21  *
22  */
23
24 package org.onap.clamp.clds.tosca.update;
25
26 import java.util.ArrayList;
27 import java.util.LinkedHashMap;
28
29 public class ToscaElement {
30
31     /**
32      * name parameter is used as "key", in the LinkedHashMap of Components.
33      */
34     private String name;
35     private String derivedFrom;
36     private String version;
37     private String typeVersion;
38     private String description;
39     private LinkedHashMap<String, Property> properties;
40
41     public ToscaElement() {
42     }
43
44     /**
45      * Constructor.
46      *
47      * @param name name
48      * @param derivedFrom derivedFrom
49      * @param description description
50      */
51     @SuppressWarnings({"unchecked", "rawtypes"})
52     public ToscaElement(String name, String derivedFrom, String description) {
53         super();
54         this.name = name;
55         this.derivedFrom = derivedFrom;
56         this.description = description;
57         this.properties = new LinkedHashMap();
58     }
59
60     public String getName() {
61         return name;
62     }
63
64     public void setName(String name) {
65         this.name = name;
66     }
67
68     public String getDerivedFrom() {
69         return derivedFrom;
70     }
71
72     public void setDerivedFrom(String derivedFrom) {
73         this.derivedFrom = derivedFrom;
74     }
75
76     public String getVersion() {
77         return version;
78     }
79
80     public void setVersion(String version) {
81         this.version = version;
82     }
83
84     public String getTypeVersion() {
85         return typeVersion;
86     }
87
88     public void setTypeVersion(String typeVersion) {
89         this.typeVersion = typeVersion;
90     }
91
92     public String getDescription() {
93         return description;
94     }
95
96     public void setDescription(String description) {
97         this.description = description;
98     }
99
100     public LinkedHashMap<String, Property> getProperties() {
101         return properties;
102     }
103
104     public void setProperties(LinkedHashMap<String, Property> properties) {
105         this.properties = properties;
106     }
107
108     public void addProperties(Property property) {
109         this.properties.put(property.getName(), property);
110     }
111
112     public ArrayList<String> propertiesNames() {
113         return new ArrayList<>(properties.keySet());
114     }
115
116     @Override
117     public String toString() {
118         return name + ": " + description + ", version: " + version + ", nb de properties: " + properties.size()
119                 + System.getProperty("line.separator") + propertiesNames();
120     }
121 }