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.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());
69 public String getOwnerId() {
70 return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_ID);
73 public void setOwnerId(String ownerId) {
74 setToscaPresentationValue(JsonPresentationFields.OWNER_ID, ownerId);
77 public String getOwnerName() {
78 return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_NAME);
81 public void setOwnerName(String ownerName) {
82 setToscaPresentationValue(JsonPresentationFields.OWNER_NAME, ownerName);
85 public String getMinOccurrences() {
86 return (String) getToscaPresentationValue(JsonPresentationFields.MIN_OCCURRENCES);
89 public void setMinOccurrences(String minOccurrences) {
90 setToscaPresentationValue(JsonPresentationFields.MIN_OCCURRENCES, minOccurrences);
93 public String getMaxOccurrences() {
94 return (String) getToscaPresentationValue(JsonPresentationFields.MAX_OCCURRENCES);
97 public void setMaxOccurrences(String maxOccurrences) {
98 setToscaPresentationValue(JsonPresentationFields.MAX_OCCURRENCES, maxOccurrences);
100 public String getLeftOccurrences() {
101 return (String) getToscaPresentationValue(JsonPresentationFields.LEFT_OCCURRENCES);
104 public void setLeftOccurrences(String leftOccurrences) {
105 setToscaPresentationValue(JsonPresentationFields.LEFT_OCCURRENCES, leftOccurrences);
108 public String getUniqueId() {
109 return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
112 public void setUniqueId(String uniqueId) {
113 setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
116 public String getDescription() {
117 return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
120 public void setDescription(String description) {
121 setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
124 public String getName() {
125 return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
128 public void setName(String name) {
129 setToscaPresentationValue(JsonPresentationFields.NAME, name);
132 public String getType() {
133 return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
136 public void setType(String type) {
137 setToscaPresentationValue(JsonPresentationFields.TYPE, type);
140 public List<String> getValidSourceTypes() {
141 return (List<String>) getToscaPresentationValue(JsonPresentationFields.VALID_SOURCE_TYPE);
144 public void setValidSourceTypes(List<String> validSourceTypes) {
145 setToscaPresentationValue(JsonPresentationFields.VALID_SOURCE_TYPE, validSourceTypes);
148 public List<String> getCapabilitySources() {
149 return (List<String>) getToscaPresentationValue(JsonPresentationFields.CAPABILITY_SOURCES);
152 public void setCapabilitySources(List<String> capabilitySources) {
153 setToscaPresentationValue(JsonPresentationFields.CAPABILITY_SOURCES, capabilitySources);
156 public void setPath(List<String> path){
157 setToscaPresentationValue(JsonPresentationFields.PATH, path);
159 public List<String> getPath() {
160 return (List<String>) getToscaPresentationValue(JsonPresentationFields.PATH);
162 public void setSource(String source){
163 setToscaPresentationValue(JsonPresentationFields.SOURCE, source);
165 public String getSource() {
166 return (String) getToscaPresentationValue(JsonPresentationFields.SOURCE);
168 public void addToPath(String elementInPath){
169 List<String> path = getPath();
171 path = new ArrayList<>();
173 path.add(elementInPath);
180 public int hashCode() {
181 final int prime = 31;
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();
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();
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());
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());
217 public boolean equals(Object obj) {
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();
237 if (getClass() != obj.getClass())
239 CapabilityDataDefinition other = (CapabilityDataDefinition) obj;
240 if (capabilitySources == null) {
241 if (other.getCapabilitySources() != null)
243 } else if (!capabilitySources.equals(other.getCapabilitySources()))
245 if (description == null) {
246 if (other.getDescription() != null)
248 } else if (!description.equals(other.getDescription()))
250 if (maxOccurrences == null) {
251 if (other.getMaxOccurrences() != null)
253 } else if (!maxOccurrences.equals(other.getMaxOccurrences()))
255 if (minOccurrences == null) {
256 if (other.getMinOccurrences() != null)
258 } else if (!minOccurrences.equals(other.getMinOccurrences()))
261 if (other.getName() != null)
263 } else if (!name.equals(other.getName()))
265 if (ownerId == null) {
266 if (other.getOwnerId() != null)
268 } else if (!ownerId.equals(other.getOwnerId()))
270 if (ownerName == null) {
271 if (other.getOwnerName() != null)
273 } else if (!ownerName.equals(other.getOwnerName()))
276 if (other.getType() != null)
278 } else if (!type.equals(other.getType()))
280 if (uniqueId == null) {
281 if (other.getUniqueId() != null)
283 } else if (!uniqueId.equals(other.getUniqueId()))
285 if (validSourceTypes == null) {
286 if (other.getValidSourceTypes() != null)
288 } else if (!validSourceTypes.equals(other.getValidSourceTypes()))
290 if (leftOccurrences == null) {
291 if (other.getLeftOccurrences() != null)
293 } else if (!leftOccurrences.equals(other.getLeftOccurrences()))
296 if (other.getPath() != null)
298 } else if (!path.equals(other.getPath()))
300 if (source == null) {
301 if (other.getSource() != null)
303 } else if (!source.equals(other.getSource()))
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();
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 + "]";