[sdc] rebase update
[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.setValidSourceTypes( a.getValidSourceTypes());
56                 this.setCapabilitySources( a.getCapabilitySources());
57                 this.setOwnerId( a.getOwnerId());
58                 this.setOwnerName( a.getOwnerName());
59                 this.setMinOccurrences(  a.getMinOccurrences());
60                 this.setMaxOccurrences(  a.getMaxOccurrences());
61                 this.setLeftOccurrences(a.getLeftOccurrences());
62                 this.setPath(a.getPath());
63                 this.setSource(a.getSource());
64                 
65         }
66
67         
68
69         public String getOwnerId() {
70                 return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_ID);
71         }
72
73         public void setOwnerId(String ownerId) {
74                 setToscaPresentationValue(JsonPresentationFields.OWNER_ID, ownerId);
75         }
76
77         public String getOwnerName() {
78                 return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_NAME);
79         }
80
81         public void setOwnerName(String ownerName) {
82                 setToscaPresentationValue(JsonPresentationFields.OWNER_NAME, ownerName);
83         }
84
85         public String getMinOccurrences() {
86                 return (String) getToscaPresentationValue(JsonPresentationFields.MIN_OCCURRENCES);
87         }
88
89         public void setMinOccurrences(String minOccurrences) {
90                 setToscaPresentationValue(JsonPresentationFields.MIN_OCCURRENCES, minOccurrences);
91         }
92
93         public String getMaxOccurrences() {
94                 return (String) getToscaPresentationValue(JsonPresentationFields.MAX_OCCURRENCES);
95         }
96
97         public void setMaxOccurrences(String maxOccurrences) {
98                 setToscaPresentationValue(JsonPresentationFields.MAX_OCCURRENCES, maxOccurrences);
99         }
100         public String getLeftOccurrences() {
101                 return (String) getToscaPresentationValue(JsonPresentationFields.LEFT_OCCURRENCES);
102         }
103
104         public void setLeftOccurrences(String leftOccurrences) {
105                 setToscaPresentationValue(JsonPresentationFields.LEFT_OCCURRENCES, leftOccurrences);
106         }
107         
108         public String getUniqueId() {
109                 return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
110         }
111
112         public void setUniqueId(String uniqueId) {
113                 setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
114         }
115
116         public String getDescription() {
117                 return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
118         }
119
120         public void setDescription(String description) {
121                 setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
122         }
123
124         public String getName() {
125                 return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
126         }
127
128         public void setName(String name) {
129                 setToscaPresentationValue(JsonPresentationFields.NAME, name);
130         }
131
132         public String getType() {
133                 return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
134         }
135
136         public void setType(String type) {
137                 setToscaPresentationValue(JsonPresentationFields.TYPE, type);
138         }
139
140         public List<String> getValidSourceTypes() {
141                 return (List<String>) getToscaPresentationValue(JsonPresentationFields.VALID_SOURCE_TYPE);
142         }
143
144         public void setValidSourceTypes(List<String> validSourceTypes) {
145                 setToscaPresentationValue(JsonPresentationFields.VALID_SOURCE_TYPE, validSourceTypes);
146         }
147
148         public List<String> getCapabilitySources() {
149                 return (List<String>) getToscaPresentationValue(JsonPresentationFields.CAPABILITY_SOURCES);
150         }
151         
152         public void setCapabilitySources(List<String> capabilitySources) {
153                 setToscaPresentationValue(JsonPresentationFields.CAPABILITY_SOURCES, capabilitySources);
154         }
155
156         public void setPath(List<String> path){
157                 setToscaPresentationValue(JsonPresentationFields.PATH, path);
158         }
159         public List<String> getPath() {
160                 return (List<String>) getToscaPresentationValue(JsonPresentationFields.PATH);
161         }
162         public void setSource(String source){
163                 setToscaPresentationValue(JsonPresentationFields.SOURCE, source);
164         }
165         public String getSource() {
166                 return (String) getToscaPresentationValue(JsonPresentationFields.SOURCE);
167         }
168         public void addToPath(String elementInPath){
169                 List<String> path = getPath();
170                 if ( path == null ){
171                         path = new ArrayList<>();
172                 }
173                 path.add(elementInPath);
174                 setPath(path);
175         }
176         
177
178         
179         @Override
180         public int hashCode() {
181                 final int prime = 31;
182                 int result = 1;
183                 
184                 String uniqueId = this.getUniqueId();           
185                 String description = this.getDescription();
186                 String name = this.getName();
187                 String type = this.getType();
188                 List<String> validSourceTypes = this.getValidSourceTypes();
189                 List<String> capabilitySources = this.getCapabilitySources();
190                 List<String> path = this.getPath();
191                 
192                 String ownerId = this.getOwnerId();
193                 String ownerName = this.getOwnerName();
194                 String minOccurrences = this.getMinOccurrences();
195                 String maxOccurrences = this.getMaxOccurrences();
196                 String leftOccurrences = getLeftOccurrences();
197                 String source = getSource();
198                 
199                 result = prime * result + ((capabilitySources == null) ? 0 : capabilitySources.hashCode());
200                 result = prime * result + ((description == null) ? 0 : description.hashCode());
201                 result = prime * result + ((maxOccurrences == null) ? 0 : maxOccurrences.hashCode());
202                 result = prime * result + ((minOccurrences == null) ? 0 : minOccurrences.hashCode());
203                 result = prime * result + ((name == null) ? 0 : name.hashCode());
204                 result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode());
205                 result = prime * result + ((ownerName == null) ? 0 : ownerName.hashCode());
206         
207                 result = prime * result + ((type == null) ? 0 : type.hashCode());
208                 result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
209                 result = prime * result + ((validSourceTypes == null) ? 0 : validSourceTypes.hashCode());
210                 result = prime * result + ((leftOccurrences == null) ? 0 : leftOccurrences.hashCode());
211                 result = prime * result + ((path == null) ? 0 : path.hashCode());
212                 result = prime * result + ((source == null) ? 0 : source.hashCode());
213                 return result;
214         }
215
216         @Override
217         public boolean equals(Object obj) {
218                 
219                 String uniqueId = this.getUniqueId();           
220                 String description = this.getDescription();
221                 String name = this.getName();
222                 String type = this.getType();
223                 List<String> validSourceTypes = this.getValidSourceTypes();
224                 List<String> capabilitySources = this.getCapabilitySources();
225                 String ownerId = this.getOwnerId();
226                 String ownerName = this.getOwnerName();
227                 String minOccurrences = this.getMinOccurrences();
228                 String maxOccurrences = this.getMaxOccurrences();
229                 String leftOccurrences = getLeftOccurrences();
230                 List<String> path = this.getPath();
231                 String source = getSource();
232                 
233                 if (this == obj)
234                         return true;
235                 if (obj == null)
236                         return false;
237                 if (getClass() != obj.getClass())
238                         return false;
239                 CapabilityDataDefinition other = (CapabilityDataDefinition) obj;
240                 if (capabilitySources == null) {
241                         if (other.getCapabilitySources() != null)
242                                 return false;
243                 } else if (!capabilitySources.equals(other.getCapabilitySources()))
244                         return false;
245                 if (description == null) {
246                         if (other.getDescription() != null)
247                                 return false;
248                 } else if (!description.equals(other.getDescription()))
249                         return false;
250                 if (maxOccurrences == null) {
251                         if (other.getMaxOccurrences() != null)
252                                 return false;
253                 } else if (!maxOccurrences.equals(other.getMaxOccurrences()))
254                         return false;
255                 if (minOccurrences == null) {
256                         if (other.getMinOccurrences() != null)
257                                 return false;
258                 } else if (!minOccurrences.equals(other.getMinOccurrences()))
259                         return false;
260                 if (name == null) {
261                         if (other.getName() != null)
262                                 return false;
263                 } else if (!name.equals(other.getName()))
264                         return false;
265                 if (ownerId == null) {
266                         if (other.getOwnerId() != null)
267                                 return false;
268                 } else if (!ownerId.equals(other.getOwnerId()))
269                         return false;
270                 if (ownerName == null) {
271                         if (other.getOwnerName() != null)
272                                 return false;
273                 } else if (!ownerName.equals(other.getOwnerName()))
274                         return false;
275                 if (type == null) {
276                         if (other.getType() != null)
277                                 return false;
278                 } else if (!type.equals(other.getType()))
279                         return false;
280                 if (uniqueId == null) {
281                         if (other.getUniqueId() != null)
282                                 return false;
283                 } else if (!uniqueId.equals(other.getUniqueId()))
284                         return false;
285                 if (validSourceTypes == null) {
286                         if (other.getValidSourceTypes() != null)
287                                 return false;
288                 } else if (!validSourceTypes.equals(other.getValidSourceTypes()))
289                         return false;
290                 if (leftOccurrences == null) {
291                         if (other.getLeftOccurrences() != null)
292                                 return false;
293                 } else if (!leftOccurrences.equals(other.getLeftOccurrences()))
294                         return false;
295                 if (path == null) {
296                         if (other.getPath() != null)
297                                 return false;
298                 } else if (!path.equals(other.getPath()))
299                         return false;
300                 if (source == null) {
301                         if (other.getSource() != null)
302                                 return false;
303                 } else if (!source.equals(other.getSource()))
304                         return false;
305                 return true;
306         }
307
308         @Override
309         public String toString() {
310                 String uniqueId = this.getUniqueId();           
311                 String description = this.getDescription();
312                 String name = this.getName();
313                 String type = this.getType();
314                 List<String> validSourceTypes = this.getValidSourceTypes();
315                 List<String> capabilitySources = this.getCapabilitySources();
316                 List<String> path = this.getPath();
317                 String ownerId = this.getOwnerId();
318                 String ownerName = this.getOwnerName();
319                 String minOccurrences = this.getMinOccurrences();
320                 String maxOccurrences = this.getMaxOccurrences();
321                 String source = this.getSource();
322                 
323                 
324                 return "CapabilityDefinition [uniqueId=" + uniqueId + ", description=" + description + ", name=" + name
325                                 + ", type=" + type + ", validSourceTypes=" + validSourceTypes + ", capabilitySources="
326                                 + capabilitySources + ", ownerId=" + ownerId + ", ownerName=" + ownerName
327                                 + ", minOccurrences=" + minOccurrences + ", maxOccurrences=" + maxOccurrences + ", path=" + path+ ", source=" + source + "]";
328         }
329
330 }