From 6c72be9effaeff9f2b6dbc843b2d4d1ec1b60b1b Mon Sep 17 00:00:00 2001 From: "katy.rotman" Date: Thu, 24 May 2018 14:09:26 +0300 Subject: fixing sonar violations Issue-ID: SDC-1363 Change-Id: I29b8df69d49d6ca0ba953b362f7574213e931183 Signed-off-by: katy.rotman --- .../tosca/utils/InterfacesOperationsToscaUtil.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'catalog-be/src/main/java') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java index 5a8aa7e1d5..8c9c63af03 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java @@ -47,12 +47,15 @@ public class InterfacesOperationsToscaUtil { private static final String OPERATIONS_KEY = "operations"; private static final String DEFAULT = "default"; - private static final String _DEFAULT = "_default"; + private static final String DEFAULT_HAS_UNDERSCORE = "_default"; private static final String DOT = "."; private static final String DEFAULT_INPUT_TYPE = "string"; private static final String SELF = "SELF"; private static final String GET_PROPERTY = "get_property"; - public static final String DEFAULTP = "defaultp"; + private static final String DEFAULTP = "defaultp"; + + private InterfacesOperationsToscaUtil() { + } /** * Creates the interface_types element @@ -67,7 +70,7 @@ public class InterfacesOperationsToscaUtil { } final Map interfaces = ((Resource) component).getInterfaces(); - if ( MapUtils.isEmpty(interfaces)) { + if (MapUtils.isEmpty(interfaces)) { return null; } @@ -78,8 +81,8 @@ public class InterfacesOperationsToscaUtil { final Map operations = interfaceDefinition.getOperations(); Map toscaOperations = new HashMap<>(); - for (String operationId : operations.keySet()) { - toscaOperations.put(operations.get(operationId).getName(), + for (Map.Entry operationEntry : operations.entrySet()) { + toscaOperations.put(operationEntry.getValue().getName(), null); //currently not initializing any of the operations' fields as it is not needed } @@ -108,7 +111,7 @@ public class InterfacesOperationsToscaUtil { } final Map interfaces = ((Resource) component).getInterfaces(); - if ( MapUtils.isEmpty(interfaces)) { + if (MapUtils.isEmpty(interfaces)) { return; } for (InterfaceDefinition interfaceDefinition : interfaces.values()) { @@ -150,23 +153,21 @@ public class InterfacesOperationsToscaUtil { * @param operationsMap the map to update */ private static void handleDefaults(Map operationsMap) { - for (String key : operationsMap.keySet()) { - Object value = operationsMap.get(key); + for (Map.Entry operationEntry : operationsMap.entrySet()) { + final Object value = operationEntry.getValue(); if (value instanceof Map) { handleDefaults((Map) value); } + final String key = operationEntry.getKey(); if (key.equals(DEFAULTP)) { Object removed = operationsMap.remove(key); operationsMap.put(DEFAULT, removed); } } - - } private static String getLastPartOfName(String toscaResourceName) { return toscaResourceName.substring(toscaResourceName.lastIndexOf(DOT) + 1); - } private static boolean isArtifactPresent(Map.Entry operationEntry) { @@ -215,9 +216,8 @@ public class InterfacesOperationsToscaUtil { if (objectAsMap.containsKey(DEFAULT)) { Object defaultValue = objectAsMap.get(DEFAULT); objectAsMap.remove(DEFAULT); - objectAsMap.put(_DEFAULT, defaultValue); + objectAsMap.put(DEFAULT_HAS_UNDERSCORE, defaultValue); } return objectAsMap; } - } -- cgit 1.2.3-korg