diff options
author | 2018-03-21 09:11:30 +0200 | |
---|---|---|
committer | 2018-03-21 12:24:17 +0000 | |
commit | 298c383225d728eb6a04e4b8cb03472f4990de7e (patch) | |
tree | 5b975c4620ad350ff46060f1427a6accfc12ec2c /common/openecomp-tosca-datatype/src/main/java/org/openecomp | |
parent | f59a22539d5b372e2425c39963547985379d6990 (diff) |
Handle OperationDefinition in Tosca Data Model
Change-Id: Ib1a7f0c5548fc9c7a98cff1182ff02300353443d
Issue-ID: SDC-1154
Signed-off-by: shiria <shiri.amichai@amdocs.com>
Diffstat (limited to 'common/openecomp-tosca-datatype/src/main/java/org/openecomp')
4 files changed, 75 insertions, 54 deletions
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java index 2f629ef54a..8d6ace2043 100644 --- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java @@ -15,47 +15,7 @@ */ package org.openecomp.sdc.tosca.datatypes.model; -import org.apache.commons.collections4.MapUtils; +public abstract class InterfaceDefinition { + public abstract void addOperation(String operationName, OperationDefinition operationDefinition); -import java.util.HashMap; -import java.util.Map; - -public class InterfaceDefinition { - protected Map<String, OperationDefinition> operations; - - public Map<String, OperationDefinition> getOperations() { - return operations; - } - - public void setOperations( - Map<String, OperationDefinition> operations) { - this.operations = operations; - } - - public void addOperation(String operationName, OperationDefinition operationDefinition) { - if (MapUtils.isEmpty(this.operations)) { - this.operations = new HashMap<>(); - } - this.operations.put(operationName, operationDefinition); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof InterfaceDefinition)) { - return false; - } - - InterfaceDefinition that = (InterfaceDefinition) o; - - return getOperations() != null ? getOperations().equals(that.getOperations()) - : that.getOperations() == null; - } - - @Override - public int hashCode() { - return getOperations() != null ? getOperations().hashCode() : 0; - } } diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java index 85dc0c571d..912e5a7b99 100644 --- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java @@ -16,12 +16,15 @@ package org.openecomp.sdc.tosca.datatypes.model; +import org.apache.commons.collections4.MapUtils; + +import java.util.HashMap; import java.util.Map; -import java.util.Objects; public class InterfaceDefinitionTemplate extends InterfaceDefinition { private Map<String, Object> inputs; + private Map<String, OperationDefinitionTemplate> operations; public Map<String, Object> getInputs() { return inputs; @@ -32,6 +35,23 @@ public class InterfaceDefinitionTemplate extends InterfaceDefinition { this.inputs = inputs; } + public Map<String, OperationDefinitionTemplate> getOperations() { + return operations; + } + + public void setOperations( + Map<String, OperationDefinitionTemplate> operations) { + this.operations = operations; + } + + public void addOperation(String operationName, OperationDefinitionTemplate operation) { + if(MapUtils.isEmpty(this.operations)) { + this.operations = new HashMap<>(); + } + + this.operations.put(operationName, operation); + } + @Override public boolean equals(Object o) { if (this == o) { @@ -40,16 +60,25 @@ public class InterfaceDefinitionTemplate extends InterfaceDefinition { if (!(o instanceof InterfaceDefinitionTemplate)) { return false; } - if (!super.equals(o)) { + + InterfaceDefinitionTemplate that = (InterfaceDefinitionTemplate) o; + + if (getInputs() != null ? !getInputs().equals(that.getInputs()) : that.getInputs() != null) { return false; } - InterfaceDefinitionTemplate that = (InterfaceDefinitionTemplate) o; - return Objects.equals(inputs, that.inputs); + return getOperations() != null ? getOperations().equals(that.getOperations()) + : that.getOperations() == null; } @Override public int hashCode() { + int result = getInputs() != null ? getInputs().hashCode() : 0; + result = 31 * result + (getOperations() != null ? getOperations().hashCode() : 0); + return result; + } - return Objects.hash(super.hashCode(), inputs); + @Override + public void addOperation(String operationName, OperationDefinition operationDefinition) { + addOperation(operationName, (OperationDefinitionTemplate)operationDefinition); } } diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionType.java index fdd11095a2..8bd1b26332 100644 --- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionType.java +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionType.java @@ -16,13 +16,16 @@ package org.openecomp.sdc.tosca.datatypes.model; +import org.apache.commons.collections4.MapUtils; + +import java.util.HashMap; import java.util.Map; -import java.util.Objects; public class InterfaceDefinitionType extends InterfaceDefinition { private String type; private Map<String, PropertyDefinition> inputs; + protected Map<String, OperationDefinitionType> operations; public String getType() { return type; @@ -41,6 +44,23 @@ public class InterfaceDefinitionType extends InterfaceDefinition { this.inputs = inputs; } + public Map<String, OperationDefinitionType> getOperations() { + return operations; + } + + public void setOperations( + Map<String, OperationDefinitionType> operations) { + this.operations = operations; + } + + public void addOperation(String operationName, OperationDefinitionType operation) { + if(MapUtils.isEmpty(this.operations)) { + this.operations = new HashMap<>(); + } + + this.operations.put(operationName, operation); + } + @Override public boolean equals(Object o) { if (this == o) { @@ -49,17 +69,29 @@ public class InterfaceDefinitionType extends InterfaceDefinition { if (!(o instanceof InterfaceDefinitionType)) { return false; } - if (!super.equals(o)) { + + InterfaceDefinitionType that = (InterfaceDefinitionType) o; + + if (getType() != null ? !getType().equals(that.getType()) : that.getType() != null) { return false; } - InterfaceDefinitionType that = (InterfaceDefinitionType) o; - return Objects.equals(type, that.type) && - Objects.equals(inputs, that.inputs); + if (getInputs() != null ? !getInputs().equals(that.getInputs()) : that.getInputs() != null) { + return false; + } + return getOperations() != null ? getOperations().equals(that.getOperations()) + : that.getOperations() == null; } @Override public int hashCode() { + int result = getType() != null ? getType().hashCode() : 0; + result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0); + result = 31 * result + (getOperations() != null ? getOperations().hashCode() : 0); + return result; + } - return Objects.hash(super.hashCode(), type, inputs); + @Override + public void addOperation(String operationName, OperationDefinition operationDefinition) { + addOperation(operationName, (OperationDefinitionType)operationDefinition); } } diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java index 155175a120..7b4be10236 100644 --- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java @@ -3,7 +3,7 @@ package org.openecomp.sdc.tosca.datatypes.model; import java.util.Map; import java.util.Objects; -public class OperationDefinitionTemplate { +public class OperationDefinitionTemplate extends OperationDefinition{ private Implementation implementation; private Map<String, Object> inputs; |