ComponentBaseTest.java enhancement and
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / elements / CapabilityDataDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.datatypes.elements;
22
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.List;
26
27 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
28 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
29
30
31
32 public class CapabilityDataDefinition extends ToscaDataDefinition implements Serializable {
33         
34         /**
35          * 
36          */
37         private static final long serialVersionUID = 7544984873506188920L;
38         public final static String MIN_OCCURRENCES = "1"; // occurrences
39         public final static String MAX_OCCURRENCES = "UNBOUNDED";
40
41         
42         public CapabilityDataDefinition() {
43                 super();
44                 this.setMinOccurrences(  MIN_OCCURRENCES );
45                 this.setMaxOccurrences(  MAX_OCCURRENCES);
46                 this.setLeftOccurrences(  MAX_OCCURRENCES);
47         }
48
49         public CapabilityDataDefinition(CapabilityDataDefinition a) {
50                 super();                
51                 this.setUniqueId(a.getUniqueId());
52                 this.setType(a.getType());              
53                 this.setDescription (  a.getDescription());
54                 this.setName(  a.getName());
55                 this.setParentName(  a.getParentName());
56                 this.setValidSourceTypes( a.getValidSourceTypes());
57                 this.setCapabilitySources( a.getCapabilitySources());
58                 this.setOwnerId( a.getOwnerId());
59                 this.setOwnerName( a.getOwnerName());
60                 this.setMinOccurrences(  a.getMinOccurrences());
61                 this.setMaxOccurrences(  a.getMaxOccurrences());
62                 this.setLeftOccurrences(a.getLeftOccurrences());
63                 this.setPath(a.getPath());
64                 this.setSource(a.getSource());
65                 
66         }
67
68         
69
70         public String getOwnerId() {
71                 return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_ID);
72         }
73
74         public void setOwnerId(String ownerId) {
75                 setToscaPresentationValue(JsonPresentationFields.OWNER_ID, ownerId);
76         }
77
78         public String getOwnerName() {
79                 return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_NAME);
80         }
81
82         public void setOwnerName(String ownerName) {
83                 setToscaPresentationValue(JsonPresentationFields.OWNER_NAME, ownerName);
84         }
85
86         public String getMinOccurrences() {
87                 return (String) getToscaPresentationValue(JsonPresentationFields.MIN_OCCURRENCES);
88         }
89
90         public void setMinOccurrences(String minOccurrences) {
91                 setToscaPresentationValue(JsonPresentationFields.MIN_OCCURRENCES, minOccurrences);
92         }
93
94         public String getMaxOccurrences() {
95                 return (String) getToscaPresentationValue(JsonPresentationFields.MAX_OCCURRENCES);
96         }
97
98         public void setMaxOccurrences(String maxOccurrences) {
99                 setToscaPresentationValue(JsonPresentationFields.MAX_OCCURRENCES, maxOccurrences);
100         }
101         public String getLeftOccurrences() {
102                 return (String) getToscaPresentationValue(JsonPresentationFields.LEFT_OCCURRENCES);
103         }
104
105         public void setLeftOccurrences(String leftOccurrences) {
106                 setToscaPresentationValue(JsonPresentationFields.LEFT_OCCURRENCES, leftOccurrences);
107         }
108         
109         public String getUniqueId() {
110                 return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
111         }
112
113         public void setUniqueId(String uniqueId) {
114                 setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
115         }
116
117         public String getDescription() {
118                 return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
119         }
120
121         public void setDescription(String description) {
122                 setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
123         }
124
125         public String getName() {
126                 return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
127         }
128
129         public void setName(String name) {
130                 setToscaPresentationValue(JsonPresentationFields.NAME, name);
131         }
132         
133         public String getParentName() {
134                 return (String) getToscaPresentationValue(JsonPresentationFields.PARENT_NAME);
135         }
136
137         public void setParentName(String parentName) {
138                 setToscaPresentationValue(JsonPresentationFields.PARENT_NAME, parentName);
139         }
140
141         public String getType() {
142                 return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
143         }
144
145         public void setType(String type) {
146                 setToscaPresentationValue(JsonPresentationFields.TYPE, type);
147         }
148
149         public List<String> getValidSourceTypes() {
150                 return (List<String>) getToscaPresentationValue(JsonPresentationFields.VALID_SOURCE_TYPE);
151         }
152
153         public void setValidSourceTypes(List<String> validSourceTypes) {
154                 setToscaPresentationValue(JsonPresentationFields.VALID_SOURCE_TYPE, validSourceTypes);
155         }
156
157         public List<String> getCapabilitySources() {
158                 return (List<String>) getToscaPresentationValue(JsonPresentationFields.CAPABILITY_SOURCES);
159         }
160         
161         public void setCapabilitySources(List<String> capabilitySources) {
162                 setToscaPresentationValue(JsonPresentationFields.CAPABILITY_SOURCES, capabilitySources);
163         }
164
165         public void setPath(List<String> path){
166                 setToscaPresentationValue(JsonPresentationFields.PATH, path);
167         }
168         public List<String> getPath() {
169                 return (List<String>) getToscaPresentationValue(JsonPresentationFields.PATH);
170         }
171         public void setSource(String source){
172                 setToscaPresentationValue(JsonPresentationFields.SOURCE, source);
173         }
174         public String getSource() {
175                 return (String) getToscaPresentationValue(JsonPresentationFields.SOURCE);
176         }
177         public void addToPath(String elementInPath){
178                 List<String> path = getPath();
179                 if ( path == null ){
180                         path = new ArrayList<>();
181                 }
182                 path.add(elementInPath);
183                 setPath(path);
184         }
185         
186
187         
188         @Override
189         public int hashCode() {
190                 final int prime = 31;
191                 int result = 1;
192                 
193                 String uniqueId = this.getUniqueId();           
194                 String description = this.getDescription();
195                 String name = this.getName();
196                 String type = this.getType();
197                 List<String> validSourceTypes = this.getValidSourceTypes();
198                 List<String> capabilitySources = this.getCapabilitySources();
199                 List<String> path = this.getPath();
200                 
201                 String ownerId = this.getOwnerId();
202                 String ownerName = this.getOwnerName();
203                 String minOccurrences = this.getMinOccurrences();
204                 String maxOccurrences = this.getMaxOccurrences();
205                 String leftOccurrences = getLeftOccurrences();
206                 String source = getSource();
207                 
208                 result = prime * result + ((capabilitySources == null) ? 0 : capabilitySources.hashCode());
209                 result = prime * result + ((description == null) ? 0 : description.hashCode());
210                 result = prime * result + ((maxOccurrences == null) ? 0 : maxOccurrences.hashCode());
211                 result = prime * result + ((minOccurrences == null) ? 0 : minOccurrences.hashCode());
212                 result = prime * result + ((name == null) ? 0 : name.hashCode());
213                 result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode());
214                 result = prime * result + ((ownerName == null) ? 0 : ownerName.hashCode());
215         
216                 result = prime * result + ((type == null) ? 0 : type.hashCode());
217                 result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
218                 result = prime * result + ((validSourceTypes == null) ? 0 : validSourceTypes.hashCode());
219                 result = prime * result + ((leftOccurrences == null) ? 0 : leftOccurrences.hashCode());
220                 result = prime * result + ((path == null) ? 0 : path.hashCode());
221                 result = prime * result + ((source == null) ? 0 : source.hashCode());
222                 return result;
223         }
224
225         @Override
226         public boolean equals(Object obj) {
227                 
228                 String uniqueId = this.getUniqueId();           
229                 String description = this.getDescription();
230                 String name = this.getName();
231                 String type = this.getType();
232                 List<String> validSourceTypes = this.getValidSourceTypes();
233                 List<String> capabilitySources = this.getCapabilitySources();
234                 String ownerId = this.getOwnerId();
235                 String ownerName = this.getOwnerName();
236                 String minOccurrences = this.getMinOccurrences();
237                 String maxOccurrences = this.getMaxOccurrences();
238                 String leftOccurrences = getLeftOccurrences();
239                 List<String> path = this.getPath();
240                 String source = getSource();
241                 
242                 if (this == obj)
243                         return true;
244                 if (obj == null)
245                         return false;
246                 if (getClass() != obj.getClass())
247                         return false;
248                 CapabilityDataDefinition other = (CapabilityDataDefinition) obj;
249                 if (capabilitySources == null) {
250                         if (other.getCapabilitySources() != null)
251                                 return false;
252                 } else if (!capabilitySources.equals(other.getCapabilitySources()))
253                         return false;
254                 if (description == null) {
255                         if (other.getDescription() != null)
256                                 return false;
257                 } else if (!description.equals(other.getDescription()))
258                         return false;
259                 if (maxOccurrences == null) {
260                         if (other.getMaxOccurrences() != null)
261                                 return false;
262                 } else if (!maxOccurrences.equals(other.getMaxOccurrences()))
263                         return false;
264                 if (minOccurrences == null) {
265                         if (other.getMinOccurrences() != null)
266                                 return false;
267                 } else if (!minOccurrences.equals(other.getMinOccurrences()))
268                         return false;
269                 if (name == null) {
270                         if (other.getName() != null)
271                                 return false;
272                 } else if (!name.equals(other.getName()))
273                         return false;
274                 if (ownerId == null) {
275                         if (other.getOwnerId() != null)
276                                 return false;
277                 } else if (!ownerId.equals(other.getOwnerId()))
278                         return false;
279                 if (ownerName == null) {
280                         if (other.getOwnerName() != null)
281                                 return false;
282                 } else if (!ownerName.equals(other.getOwnerName()))
283                         return false;
284                 if (type == null) {
285                         if (other.getType() != null)
286                                 return false;
287                 } else if (!type.equals(other.getType()))
288                         return false;
289                 if (uniqueId == null) {
290                         if (other.getUniqueId() != null)
291                                 return false;
292                 } else if (!uniqueId.equals(other.getUniqueId()))
293                         return false;
294                 if (validSourceTypes == null) {
295                         if (other.getValidSourceTypes() != null)
296                                 return false;
297                 } else if (!validSourceTypes.equals(other.getValidSourceTypes()))
298                         return false;
299                 if (leftOccurrences == null) {
300                         if (other.getLeftOccurrences() != null)
301                                 return false;
302                 } else if (!leftOccurrences.equals(other.getLeftOccurrences()))
303                         return false;
304                 if (path == null) {
305                         if (other.getPath() != null)
306                                 return false;
307                 } else if (!path.equals(other.getPath()))
308                         return false;
309                 if (source == null) {
310                         if (other.getSource() != null)
311                                 return false;
312                 } else if (!source.equals(other.getSource()))
313                         return false;
314                 return true;
315         }
316
317         @Override
318         public String toString() {
319                 String uniqueId = this.getUniqueId();           
320                 String description = this.getDescription();
321                 String name = this.getName();
322                 String type = this.getType();
323                 List<String> validSourceTypes = this.getValidSourceTypes();
324                 List<String> capabilitySources = this.getCapabilitySources();
325                 List<String> path = this.getPath();
326                 String ownerId = this.getOwnerId();
327                 String ownerName = this.getOwnerName();
328                 String minOccurrences = this.getMinOccurrences();
329                 String maxOccurrences = this.getMaxOccurrences();
330                 String source = this.getSource();
331                 
332                 
333                 return "CapabilityDefinition [uniqueId=" + uniqueId + ", description=" + description + ", name=" + name
334                                 + ", type=" + type + ", validSourceTypes=" + validSourceTypes + ", capabilitySources="
335                                 + capabilitySources + ", ownerId=" + ownerId + ", ownerName=" + ownerName
336                                 + ", minOccurrences=" + minOccurrences + ", maxOccurrences=" + maxOccurrences + ", path=" + path+ ", source=" + source + "]";
337         }
338
339 }