From 1468fdc4558bb82c025a05b03d1511018d8fd835 Mon Sep 17 00:00:00 2001 From: Talio Date: Tue, 5 Feb 2019 11:05:05 +0200 Subject: fix review comments on property assignment Change-Id: Ia986294cb552f4e26b3ebf1d1b50c9b7941553ab Issue-ID: SDC-2097 Signed-off-by: Talio --- .../elements/InterfaceInstanceDataDefinition.java | 29 ++++++++-------------- .../be/datatypes/enums/JsonPresentationFields.java | 3 ++- 2 files changed, 13 insertions(+), 19 deletions(-) (limited to 'common-be/src/main/java/org') diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceInstanceDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceInstanceDataDefinition.java index 29859cb279..113a6f4ed4 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceInstanceDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceInstanceDataDefinition.java @@ -16,7 +16,7 @@ package org.openecomp.sdc.be.datatypes.elements; -import org.apache.commons.collections.MapUtils; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; import java.io.Serializable; @@ -25,14 +25,12 @@ import java.util.Map; import java.util.Objects; public class InterfaceInstanceDataDefinition extends ToscaDataDefinition implements Serializable { - protected Map inputs; - protected Map operations; public InterfaceInstanceDataDefinition( InterfaceInstanceDataDefinition inter) { this.toscaPresentation = null; - this.inputs = inter.inputs == null? new HashMap():new HashMap<>(inter.inputs); - this.operations = new HashMap<>(inter.operations); + setInputs(inter.getInputs() == null? new HashMap():new HashMap<>(inter.getInputs())); + setOperations(new HashMap<>(inter.getOperations())); } public InterfaceInstanceDataDefinition(){ @@ -40,24 +38,19 @@ public class InterfaceInstanceDataDefinition extends ToscaDataDefinition impleme } public Map getInputs() { - return this.inputs; + return (Map)getToscaPresentationValue(JsonPresentationFields.INPUTS); } - public void setInputs( - Map inputs) { - this.inputs = inputs; + public void setInputs(Map inputs) { + setToscaPresentationValue(JsonPresentationFields.INPUTS, inputs); } public Map getOperations() { - return operations; + return (Map)getToscaPresentationValue(JsonPresentationFields.OPERATIONS); } - public void addInstanceOperation(String operationName, OperationInstance operation) { - if(MapUtils.isEmpty(this.operations)) { - this.operations = new HashMap<>(); - } - - this.operations.put(operationName, operation); + public void setOperations(Map operations) { + setToscaPresentationValue(JsonPresentationFields.OPERATIONS, operations); } @Override @@ -69,13 +62,13 @@ public class InterfaceInstanceDataDefinition extends ToscaDataDefinition impleme return false; } InterfaceInstanceDataDefinition that = (InterfaceInstanceDataDefinition) o; - return Objects.equals(inputs, that.inputs); + return Objects.equals(this.getInputs(), that.getInputs()); } @Override public int hashCode() { - return Objects.hash(inputs); + return Objects.hash(this.getInputs()); } } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java index 6829c72cb4..4d39ec1355 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java @@ -227,7 +227,8 @@ public enum JsonPresentationFields { OPERATIONS("operations", null), OPERATION_IMPLEMENTATION("implementation",null), OPERATION_INPUTS("inputs",null), - OPERATION_OUTPUTS("outputs", null); + OPERATION_OUTPUTS("outputs", null), + INPUTS("inputs", null); private String presentation; private GraphPropertyEnum storedAs; -- cgit 1.2.3-korg