summaryrefslogtreecommitdiffstats
path: root/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java
diff options
context:
space:
mode:
Diffstat (limited to 'common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java62
1 files changed, 45 insertions, 17 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java
index 92bfe593b4..78bfe50d5c 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java
@@ -17,14 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.sdc.be.datatypes.elements;
import com.google.common.collect.Lists;
-import java.util.ArrayList;
-import java.util.List;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Represents the capability of the component or component instance
*/
@@ -54,27 +56,32 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
this.setName(other.getName());
this.setParentName(other.getParentName());
this.setPreviousName(other.getPreviousName());
+
if (other.getValidSourceTypes() == null) {
this.setValidSourceTypes(Lists.newArrayList());
} else {
this.setValidSourceTypes(Lists.newArrayList(other.getValidSourceTypes()));
}
+
if (other.getCapabilitySources() == null) {
this.setCapabilitySources(Lists.newArrayList());
} else {
this.setCapabilitySources(Lists.newArrayList(other.getCapabilitySources()));
}
+
this.setOwnerId(other.getOwnerId());
this.setOwnerName(other.getOwnerName());
this.setOwnerType(other.getOwnerType());
this.setMinOccurrences(other.getMinOccurrences());
this.setMaxOccurrences(other.getMaxOccurrences());
this.setLeftOccurrences(other.getLeftOccurrences());
+
if (other.getPath() == null) {
this.setPath(Lists.newArrayList());
} else {
this.setPath(Lists.newArrayList(other.getPath()));
}
+
this.setSource(other.getSource());
this.setOwnerType(other.getOwnerType());
}
@@ -161,6 +168,14 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
}
+ public String getName() {
+ return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
+ }
+
+ public void setName(String name) {
+ setToscaPresentationValue(JsonPresentationFields.NAME, name);
+ }
+
public String getParentName() {
return (String) getToscaPresentationValue(JsonPresentationFields.PARENT_NAME);
}
@@ -177,12 +192,10 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
setToscaPresentationValue(JsonPresentationFields.PREVIOUS_NAME, previousName);
}
- @Override
public String getType() {
return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
}
- @Override
public void setType(String type) {
setToscaPresentationValue(JsonPresentationFields.TYPE, type);
}
@@ -205,23 +218,23 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
setToscaPresentationValue(JsonPresentationFields.CAPABILITY_SOURCES, capabilitySources);
}
+ public void setPath(List<String> path) {
+ setToscaPresentationValue(JsonPresentationFields.PATH, path);
+ }
+
@SuppressWarnings("unchecked")
public List<String> getPath() {
return (List<String>) getToscaPresentationValue(JsonPresentationFields.PATH);
}
- public void setPath(List<String> path) {
- setToscaPresentationValue(JsonPresentationFields.PATH, path);
+ public void setSource(String source) {
+ setToscaPresentationValue(JsonPresentationFields.SOURCE, source);
}
public String getSource() {
return (String) getToscaPresentationValue(JsonPresentationFields.SOURCE);
}
- public void setSource(String source) {
- setToscaPresentationValue(JsonPresentationFields.SOURCE, source);
- }
-
/**
* Adds the element to the path avoiding duplication
*
@@ -238,10 +251,12 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
setPath(path);
}
+
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
+
String uniqueId = this.getUniqueId();
String description = this.getDescription();
String name = this.getName();
@@ -249,12 +264,14 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
List<String> validSourceTypes = this.getValidSourceTypes();
List<String> capabilitySources = this.getCapabilitySources();
List<String> path = this.getPath();
+
String ownerId = this.getOwnerId();
String ownerName = this.getOwnerName();
String minOccurrences = this.getMinOccurrences();
String maxOccurrences = this.getMaxOccurrences();
String leftOccurrences = getLeftOccurrences();
String source = getSource();
+
result = prime * result + ((capabilitySources == null) ? 0 : capabilitySources.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((maxOccurrences == null) ? 0 : maxOccurrences.hashCode());
@@ -262,6 +279,7 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode());
result = prime * result + ((ownerName == null) ? 0 : ownerName.hashCode());
+
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
result = prime * result + ((validSourceTypes == null) ? 0 : validSourceTypes.hashCode());
@@ -273,6 +291,7 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
@Override
public boolean equals(Object obj) {
+
String uniqueId = this.getUniqueId();
String description = this.getDescription();
String name = this.getName();
@@ -286,6 +305,7 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
String leftOccurrences = getLeftOccurrences();
List<String> path = this.getPath();
String source = getSource();
+
if (this == obj) {
return true;
}
@@ -401,19 +421,29 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
String minOccurrences = this.getMinOccurrences();
String maxOccurrences = this.getMaxOccurrences();
String source = this.getSource();
- return "CapabilityDefinition [uniqueId=" + uniqueId + ", description=" + description + ", name=" + name + ", type=" + type
- + ", validSourceTypes=" + validSourceTypes + ", capabilitySources=" + capabilitySources + ", ownerId=" + ownerId + ", ownerName="
- + ownerName + ", minOccurrences=" + minOccurrences + ", maxOccurrences=" + maxOccurrences + ", path=" + path + ", source=" + source + "]";
+
+
+ return "CapabilityDefinition [uniqueId=" + uniqueId + ", description=" + description + ", name=" + name
+ + ", type=" + type + ", validSourceTypes=" + validSourceTypes + ", capabilitySources="
+ + capabilitySources + ", ownerId=" + ownerId + ", ownerName=" + ownerName
+ + ", minOccurrences=" + minOccurrences + ", maxOccurrences=" + maxOccurrences + ", path=" + path + ", source=" + source + "]";
}
public enum OwnerType {
- GROUP("group"), COMPONENT_INSTANCE("component instance"), RESOURCE("resource");
+ GROUP("group"),
+ COMPONENT_INSTANCE("component instance"),
+ RESOURCE("resource");
+
private String value;
OwnerType(String value) {
this.value = value;
}
+ public String getValue() {
+ return value;
+ }
+
public static OwnerType getByValue(String value) {
for (OwnerType type : values()) {
if (type.getValue().equals(value)) {
@@ -423,8 +453,6 @@ public class CapabilityDataDefinition extends ToscaDataDefinition {
return null;
}
- public String getValue() {
- return value;
- }
}
+
}