From d0f8678bfa7f06f06c9f1dd3cad862b1b99c3a03 Mon Sep 17 00:00:00 2001 From: Wojciech Sliwka Date: Tue, 22 May 2018 08:36:40 +0200 Subject: Fix sonar violations Fix major sonar violations in ConfigurationUtils,ConfigurationImpl, PropertyType Issue-ID: SDC-1353 Change-Id: Ic3959ba174f0a9fcd3976c9d12c6425dc4353e72 Signed-off-by: Wojciech Sliwka --- .../org/onap/sdc/generator/aai/model/Model.java | 36 ++++++++++------------ 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api') diff --git a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java index ac8dffae02..83ded46bd1 100644 --- a/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java +++ b/common/onap-sdc-artifact-generator-lib/onap-sdc-artifact-generator-api/src/main/java/org/onap/sdc/generator/aai/model/Model.java @@ -26,7 +26,6 @@ import org.onap.sdc.generator.data.GeneratorConstants; import org.onap.sdc.generator.error.IllegalAccessException; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -36,7 +35,6 @@ public abstract class Model { protected Set widgets = new HashSet<>(); private String modelId; private String modelName; - private ModelType modelType; private String modelVersion; private String modelNameVersionId; private String modelDescription; @@ -50,7 +48,7 @@ public abstract class Model { public static Model getModelFor(String toscaType) { Model modelToBeReturned = null; - while (toscaType != null && toscaType.lastIndexOf(".") != -1 && modelToBeReturned == null) { + while (isModelNotSet(toscaType, modelToBeReturned)) { switch (toscaType) { @@ -91,6 +89,7 @@ public abstract class Model { return modelToBeReturned; } + public abstract boolean addResource(Resource resource); public abstract boolean addWidget(Widget resource); @@ -152,7 +151,6 @@ public abstract class Model { * @return the model type */ public ModelType getModelType() { - //checkSupported(); if (this instanceof Service) { return ModelType.SERVICE; } else if (this instanceof Resource) { @@ -165,12 +163,10 @@ public abstract class Model { } public String getModelName() { - //checkSupported(); return modelName; } public String getModelVersion() { - //checkSupported(); return modelVersion; } @@ -180,7 +176,6 @@ public abstract class Model { } public String getModelDescription() { - //checkSupported(); return modelDescription; } @@ -190,51 +185,49 @@ public abstract class Model { * @param modelIdentInfo the model ident info */ public void populateModelIdentificationInformation(Map modelIdentInfo) { - Iterator iter = modelIdentInfo.keySet().iterator(); - String property; - while (iter.hasNext()) { - switch (property = iter.next()) { + for (Map.Entry entry : modelIdentInfo.entrySet()) { + String property=entry.getKey(); + switch (property) { case "vfModuleModelInvariantUUID": case "serviceInvariantUUID": case "resourceInvariantUUID": case "invariantUUID": case "providing_service_invariant_uuid": - modelId = modelIdentInfo.get(property); + modelId = entry.getValue(); break; case "vfModuleModelUUID": case "resourceUUID": case "serviceUUID": case "UUID": case "providing_service_uuid": - modelNameVersionId = modelIdentInfo.get(property); + modelNameVersionId = entry.getValue(); break; case "vfModuleModelVersion": case "serviceVersion": case "resourceversion": case "version": - modelVersion = modelIdentInfo.get(property); + modelVersion = entry.getValue(); break; case "vfModuleModelName": case "serviceName": case "resourceName": case "name": - modelName = modelIdentInfo.get(property); + modelName = entry.getValue(); break; case "serviceDescription": case "resourceDescription": case "vf_module_description": case "description": - modelDescription = modelIdentInfo.get(property); + modelDescription = entry.getValue(); break; case "providing_service_name": - modelName = modelIdentInfo.get(property); - modelDescription = modelIdentInfo.get(property); + modelName = entry.getValue(); + modelDescription = entry.getValue(); break; default: break; } - property = null; } @@ -249,11 +242,14 @@ public abstract class Model { return widgets; } - private void checkSupported() throws IllegalAccessException { + private void checkSupported() { if (this instanceof Widget) { throw new IllegalAccessException(GeneratorConstants .GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION); } } + private static boolean isModelNotSet(String toscaType, Model modelToBeReturned) { + return toscaType != null && toscaType.lastIndexOf(".") != -1 && modelToBeReturned == null; + } } -- cgit 1.2.3-korg