2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.datatypes.elements;
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.List;
27 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
28 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
32 public class CapabilityDataDefinition extends ToscaDataDefinition implements Serializable {
37 private static final long serialVersionUID = 7544984873506188920L;
38 public final static String MIN_OCCURRENCES = "1"; // occurrences
39 public final static String MAX_OCCURRENCES = "UNBOUNDED";
42 public CapabilityDataDefinition() {
44 this.setMinOccurrences( MIN_OCCURRENCES );
45 this.setMaxOccurrences( MAX_OCCURRENCES);
46 this.setLeftOccurrences( MAX_OCCURRENCES);
49 public CapabilityDataDefinition(CapabilityDataDefinition a) {
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());
70 public String getOwnerId() {
71 return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_ID);
74 public void setOwnerId(String ownerId) {
75 setToscaPresentationValue(JsonPresentationFields.OWNER_ID, ownerId);
78 public String getOwnerName() {
79 return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_NAME);
82 public void setOwnerName(String ownerName) {
83 setToscaPresentationValue(JsonPresentationFields.OWNER_NAME, ownerName);
86 public String getMinOccurrences() {
87 return (String) getToscaPresentationValue(JsonPresentationFields.MIN_OCCURRENCES);
90 public void setMinOccurrences(String minOccurrences) {
91 setToscaPresentationValue(JsonPresentationFields.MIN_OCCURRENCES, minOccurrences);
94 public String getMaxOccurrences() {
95 return (String) getToscaPresentationValue(JsonPresentationFields.MAX_OCCURRENCES);
98 public void setMaxOccurrences(String maxOccurrences) {
99 setToscaPresentationValue(JsonPresentationFields.MAX_OCCURRENCES, maxOccurrences);
101 public String getLeftOccurrences() {
102 return (String) getToscaPresentationValue(JsonPresentationFields.LEFT_OCCURRENCES);
105 public void setLeftOccurrences(String leftOccurrences) {
106 setToscaPresentationValue(JsonPresentationFields.LEFT_OCCURRENCES, leftOccurrences);
109 public String getUniqueId() {
110 return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
113 public void setUniqueId(String uniqueId) {
114 setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
117 public String getDescription() {
118 return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
121 public void setDescription(String description) {
122 setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
125 public String getName() {
126 return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
129 public void setName(String name) {
130 setToscaPresentationValue(JsonPresentationFields.NAME, name);
133 public String getParentName() {
134 return (String) getToscaPresentationValue(JsonPresentationFields.PARENT_NAME);
137 public void setParentName(String parentName) {
138 setToscaPresentationValue(JsonPresentationFields.PARENT_NAME, parentName);
141 public String getType() {
142 return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
145 public void setType(String type) {
146 setToscaPresentationValue(JsonPresentationFields.TYPE, type);
149 public List<String> getValidSourceTypes() {
150 return (List<String>) getToscaPresentationValue(JsonPresentationFields.VALID_SOURCE_TYPE);
153 public void setValidSourceTypes(List<String> validSourceTypes) {
154 setToscaPresentationValue(JsonPresentationFields.VALID_SOURCE_TYPE, validSourceTypes);
157 public List<String> getCapabilitySources() {
158 return (List<String>) getToscaPresentationValue(JsonPresentationFields.CAPABILITY_SOURCES);
161 public void setCapabilitySources(List<String> capabilitySources) {
162 setToscaPresentationValue(JsonPresentationFields.CAPABILITY_SOURCES, capabilitySources);
165 public void setPath(List<String> path){
166 setToscaPresentationValue(JsonPresentationFields.PATH, path);
168 public List<String> getPath() {
169 return (List<String>) getToscaPresentationValue(JsonPresentationFields.PATH);
171 public void setSource(String source){
172 setToscaPresentationValue(JsonPresentationFields.SOURCE, source);
174 public String getSource() {
175 return (String) getToscaPresentationValue(JsonPresentationFields.SOURCE);
177 public void addToPath(String elementInPath){
178 List<String> path = getPath();
180 path = new ArrayList<>();
182 path.add(elementInPath);
189 public int hashCode() {
190 final int prime = 31;
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();
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();
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());
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());
226 public boolean equals(Object obj) {
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();
246 if (getClass() != obj.getClass())
248 CapabilityDataDefinition other = (CapabilityDataDefinition) obj;
249 if (capabilitySources == null) {
250 if (other.getCapabilitySources() != null)
252 } else if (!capabilitySources.equals(other.getCapabilitySources()))
254 if (description == null) {
255 if (other.getDescription() != null)
257 } else if (!description.equals(other.getDescription()))
259 if (maxOccurrences == null) {
260 if (other.getMaxOccurrences() != null)
262 } else if (!maxOccurrences.equals(other.getMaxOccurrences()))
264 if (minOccurrences == null) {
265 if (other.getMinOccurrences() != null)
267 } else if (!minOccurrences.equals(other.getMinOccurrences()))
270 if (other.getName() != null)
272 } else if (!name.equals(other.getName()))
274 if (ownerId == null) {
275 if (other.getOwnerId() != null)
277 } else if (!ownerId.equals(other.getOwnerId()))
279 if (ownerName == null) {
280 if (other.getOwnerName() != null)
282 } else if (!ownerName.equals(other.getOwnerName()))
285 if (other.getType() != null)
287 } else if (!type.equals(other.getType()))
289 if (uniqueId == null) {
290 if (other.getUniqueId() != null)
292 } else if (!uniqueId.equals(other.getUniqueId()))
294 if (validSourceTypes == null) {
295 if (other.getValidSourceTypes() != null)
297 } else if (!validSourceTypes.equals(other.getValidSourceTypes()))
299 if (leftOccurrences == null) {
300 if (other.getLeftOccurrences() != null)
302 } else if (!leftOccurrences.equals(other.getLeftOccurrences()))
305 if (other.getPath() != null)
307 } else if (!path.equals(other.getPath()))
309 if (source == null) {
310 if (other.getSource() != null)
312 } else if (!source.equals(other.getSource()))
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();
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 + "]";