From 8b6be264a6f4b658632b7e263737eaae92e337aa Mon Sep 17 00:00:00 2001 From: talio Date: Thu, 15 Mar 2018 14:46:20 +0200 Subject: Interface definition Add separate Interface definition for node type and node template Change-Id: I0c4446227dd096959158fd4a4741cb5aa043e495 Issue-ID: SDC-1043 Signed-off-by: talio --- .../sdc/tosca/datatypes/model/Implementation.java | 61 ++++++++++++++++++++ .../tosca/datatypes/model/InterfaceDefinition.java | 48 +++++----------- .../model/InterfaceDefinitionTemplate.java | 55 ++++++++++++++++++ .../datatypes/model/InterfaceDefinitionType.java | 65 ++++++++++++++++++++++ .../sdc/tosca/datatypes/model/InterfaceType.java | 39 +++---------- .../sdc/tosca/datatypes/model/NodeTemplate.java | 64 ++++++--------------- .../tosca/datatypes/model/OperationDefinition.java | 41 ++------------ .../model/OperationDefinitionTemplate.java | 45 +++++++++++++++ .../datatypes/model/OperationDefinitionType.java | 46 +++++++++++++++ 9 files changed, 317 insertions(+), 147 deletions(-) create mode 100644 common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Implementation.java create mode 100644 common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java create mode 100644 common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionType.java create mode 100644 common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java create mode 100644 common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionType.java (limited to 'common') diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Implementation.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Implementation.java new file mode 100644 index 0000000000..cb79691b21 --- /dev/null +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Implementation.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Objects; + + +public class Implementation { + + private String primary; + private List dependencies; + + public String getPrimary() { + return primary; + } + + public void setPrimary(String primary) { + this.primary = primary; + } + + public List getDependencies() { + return dependencies; + } + + public void setDependencies(List dependencies) { + this.dependencies = dependencies; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Implementation)) { + return false; + } + Implementation that = (Implementation) o; + return Objects.equals(primary, that.primary) && + Objects.equals(dependencies, that.dependencies); + } + + @Override + public int hashCode() { + + return Objects.hash(primary, dependencies); + } +} 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 745f49dcfa..2f629ef54a 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 @@ -1,9 +1,6 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2018 European Support Limited + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,44 +12,26 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END========================================================= */ - 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 InterfaceDefinition { - - private String type; - private Map inputs; - private Map operations; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Map getInputs() { - return inputs; - } - - public void setInputs( - Map inputs) { - this.inputs = inputs; - } + protected Map operations; public Map getOperations() { return operations; } + public void setOperations( + Map operations) { + this.operations = operations; + } + public void addOperation(String operationName, OperationDefinition operationDefinition) { if (MapUtils.isEmpty(this.operations)) { this.operations = new HashMap<>(); @@ -68,14 +47,15 @@ public class InterfaceDefinition { if (!(o instanceof InterfaceDefinition)) { return false; } + InterfaceDefinition that = (InterfaceDefinition) o; - return Objects.equals(type, that.type) && - Objects.equals(inputs, that.inputs) && - Objects.equals(operations, that.operations); + + return getOperations() != null ? getOperations().equals(that.getOperations()) + : that.getOperations() == null; } @Override public int hashCode() { - return Objects.hash(type, inputs, operations); + 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 new file mode 100644 index 0000000000..85dc0c571d --- /dev/null +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java @@ -0,0 +1,55 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Map; +import java.util.Objects; + +public class InterfaceDefinitionTemplate extends InterfaceDefinition { + + private Map inputs; + + public Map getInputs() { + return inputs; + } + + public void setInputs( + Map inputs) { + this.inputs = inputs; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof InterfaceDefinitionTemplate)) { + return false; + } + if (!super.equals(o)) { + return false; + } + InterfaceDefinitionTemplate that = (InterfaceDefinitionTemplate) o; + return Objects.equals(inputs, that.inputs); + } + + @Override + public int hashCode() { + + return Objects.hash(super.hashCode(), inputs); + } +} 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 new file mode 100644 index 0000000000..fdd11095a2 --- /dev/null +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinitionType.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Map; +import java.util.Objects; + +public class InterfaceDefinitionType extends InterfaceDefinition { + + private String type; + private Map inputs; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Map getInputs() { + return inputs; + } + + public void setInputs( + Map inputs) { + this.inputs = inputs; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof InterfaceDefinitionType)) { + return false; + } + if (!super.equals(o)) { + return false; + } + InterfaceDefinitionType that = (InterfaceDefinitionType) o; + return Objects.equals(type, that.type) && + Objects.equals(inputs, that.inputs); + } + + @Override + public int hashCode() { + + return Objects.hash(super.hashCode(), type, inputs); + } +} diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java index 22d8e7c6ff..f32ebc39dd 100644 --- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java @@ -24,6 +24,7 @@ import org.apache.commons.collections4.MapUtils; import java.util.HashMap; import java.util.Map; +import java.util.Objects; public class InterfaceType { private String derived_from; @@ -98,40 +99,18 @@ public class InterfaceType { if (!(o instanceof InterfaceType)) { return false; } - InterfaceType that = (InterfaceType) o; - - if (getDerived_from() != null ? !getDerived_from().equals(that.getDerived_from()) - : that.getDerived_from() != null) { - return false; - } - if (getVersion() != null ? !getVersion().equals(that.getVersion()) - : that.getVersion() != null) { - return false; - } - if (getMetadata() != null ? !getMetadata().equals(that.getMetadata()) - : that.getMetadata() != null) { - return false; - } - if (getDescription() != null ? !getDescription().equals(that.getDescription()) - : that.getDescription() != null) { - return false; - } - if (getInputs() != null ? !getInputs().equals(that.getInputs()) : that.getInputs() != null) { - return false; - } - return getOperations() != null ? getOperations().equals(that.getOperations()) - : that.getOperations() == null; + return Objects.equals(derived_from, that.derived_from) && + Objects.equals(version, that.version) && + Objects.equals(metadata, that.metadata) && + Objects.equals(description, that.description) && + Objects.equals(inputs, that.inputs) && + Objects.equals(operations, that.operations); } @Override public int hashCode() { - int result = getDerived_from() != null ? getDerived_from().hashCode() : 0; - result = 31 * result + (getVersion() != null ? getVersion().hashCode() : 0); - result = 31 * result + (getMetadata() != null ? getMetadata().hashCode() : 0); - result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0); - result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0); - result = 31 * result + (getOperations() != null ? getOperations().hashCode() : 0); - return result; + + return Objects.hash(derived_from, version, metadata, description, inputs, operations); } } diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java index 01b1c6a959..6ce1ce03d8 100644 --- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java @@ -24,6 +24,7 @@ import org.openecomp.sdc.tosca.services.YamlUtil; import java.util.List; import java.util.Map; +import java.util.Objects; public class NodeTemplate implements Template { @@ -151,57 +152,26 @@ public class NodeTemplate implements Template { if (!(o instanceof NodeTemplate)) { return false; } - NodeTemplate that = (NodeTemplate) o; - - if (type != null ? !type.equals(that.type) : that.type != null) { - return false; - } - if (description != null ? !description.equals(that.description) : that.description != null) { - return false; - } - if (directives != null ? !directives.equals(that.directives) : that.directives != null) { - return false; - } - if (properties != null ? !properties.equals(that.properties) : that.properties != null) { - return false; - } - if (attributes != null ? !attributes.equals(that.attributes) : that.attributes != null) { - return false; - } - if (requirements != null ? !requirements.equals(that.requirements) - : that.requirements != null) { - return false; - } - if (capabilities != null ? !capabilities.equals(that.capabilities) - : that.capabilities != null) { - return false; - } - if (interfaces != null ? !interfaces.equals(that.interfaces) : that.interfaces != null) { - return false; - } - if (artifacts != null ? !artifacts.equals(that.artifacts) : that.artifacts != null) { - return false; - } - if (node_filter != null ? !node_filter.equals(that.node_filter) : that.node_filter != null) { - return false; - } - return copy != null ? copy.equals(that.copy) : that.copy == null; + return Objects.equals(type, that.type) && + Objects.equals(description, that.description) && + Objects.equals(metadata, that.metadata) && + Objects.equals(directives, that.directives) && + Objects.equals(properties, that.properties) && + Objects.equals(attributes, that.attributes) && + Objects.equals(requirements, that.requirements) && + Objects.equals(capabilities, that.capabilities) && + Objects.equals(interfaces, that.interfaces) && + Objects.equals(artifacts, that.artifacts) && + Objects.equals(node_filter, that.node_filter) && + Objects.equals(copy, that.copy); } @Override public int hashCode() { - int result = type != null ? type.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (directives != null ? directives.hashCode() : 0); - result = 31 * result + (properties != null ? properties.hashCode() : 0); - result = 31 * result + (attributes != null ? attributes.hashCode() : 0); - result = 31 * result + (requirements != null ? requirements.hashCode() : 0); - result = 31 * result + (capabilities != null ? capabilities.hashCode() : 0); - result = 31 * result + (interfaces != null ? interfaces.hashCode() : 0); - result = 31 * result + (artifacts != null ? artifacts.hashCode() : 0); - result = 31 * result + (node_filter != null ? node_filter.hashCode() : 0); - result = 31 * result + (copy != null ? copy.hashCode() : 0); - return result; + + return Objects + .hash(type, description, metadata, directives, properties, attributes, requirements, + capabilities, interfaces, artifacts, node_filter, copy); } } diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinition.java index 591e94ee1d..bdfe937b1e 100644 --- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinition.java +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinition.java @@ -1,12 +1,10 @@ package org.openecomp.sdc.tosca.datatypes.model; -import java.util.Map; +import java.util.Objects; public class OperationDefinition { - private String description; - private String implementation; - private Map inputs; + protected String description; public String getDescription() { return description; @@ -16,23 +14,6 @@ public class OperationDefinition { this.description = description; } - public String getImplementation() { - return implementation; - } - - public void setImplementation(String implementation) { - this.implementation = implementation; - } - - public Map getInputs() { - return inputs; - } - - public void setInputs( - Map inputs) { - this.inputs = inputs; - } - @Override public boolean equals(Object o) { if (this == o) { @@ -41,25 +22,13 @@ public class OperationDefinition { if (!(o instanceof OperationDefinition)) { return false; } - OperationDefinition that = (OperationDefinition) o; - - if (getDescription() != null ? !getDescription().equals(that.getDescription()) - : that.getDescription() != null) { - return false; - } - if (getImplementation() != null ? !getImplementation().equals(that.getImplementation()) - : that.getImplementation() != null) { - return false; - } - return getInputs() != null ? getInputs().equals(that.getInputs()) : that.getInputs() == null; + return Objects.equals(description, that.description); } @Override public int hashCode() { - int result = getDescription() != null ? getDescription().hashCode() : 0; - result = 31 * result + (getImplementation() != null ? getImplementation().hashCode() : 0); - result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0); - return result; + + return Objects.hash(description); } } 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 new file mode 100644 index 0000000000..155175a120 --- /dev/null +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java @@ -0,0 +1,45 @@ +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Map; +import java.util.Objects; + +public class OperationDefinitionTemplate { + + private Implementation implementation; + private Map inputs; + + public Implementation getImplementation() { + return implementation; + } + + public void setImplementation(Implementation implementation) { + this.implementation = implementation; + } + + public Map getInputs() { + return inputs; + } + + public void setInputs(Map inputs) { + this.inputs = inputs; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof OperationDefinitionTemplate)) { + return false; + } + OperationDefinitionTemplate that = (OperationDefinitionTemplate) o; + return Objects.equals(implementation, that.implementation) && + Objects.equals(inputs, that.inputs); + } + + @Override + public int hashCode() { + + return Objects.hash(implementation, inputs); + } +} diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionType.java new file mode 100644 index 0000000000..70c6a58041 --- /dev/null +++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinitionType.java @@ -0,0 +1,46 @@ +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Map; +import java.util.Objects; + +public class OperationDefinitionType extends OperationDefinition { + + private String implementation; + private Map inputs; + + public String getImplementation() { + return implementation; + } + + public void setImplementation(String implementation) { + this.implementation = implementation; + } + + public Map getInputs() { + return inputs; + } + + public void setInputs( + Map inputs) { + this.inputs = inputs; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof OperationDefinitionType)) { + return false; + } + OperationDefinitionType that = (OperationDefinitionType) o; + return Objects.equals(implementation, that.implementation) && + Objects.equals(inputs, that.inputs); + } + + @Override + public int hashCode() { + + return Objects.hash(implementation, inputs); + } +} -- cgit 1.2.3-korg