From f00a3cc3452f6d15ac107d7e2c199b02e6338329 Mon Sep 17 00:00:00 2001 From: ojasdubey Date: Wed, 27 Dec 2017 14:42:51 +0530 Subject: Sonar fixes for module - Configuration mgmt api 1. Fixed major sonar violations configuration management api module Change-Id: I83863213e35cf092ffd1c1ff84f408318d5ce8e9 Issue-ID: SDC-343 Signed-off-by: ojasdubey --- .../org/openecomp/config/api/Configuration.java | 2 +- .../config/api/ConfigurationChangeListener.java | 1 - .../openecomp/config/api/DynamicConfiguration.java | 40 ++++++++++++---------- .../main/java/org/openecomp/config/api/Hint.java | 6 ++-- 4 files changed, 26 insertions(+), 23 deletions(-) (limited to 'common/openecomp-common-configuration-management') diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/Configuration.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/Configuration.java index 4d82dad965..07db4ab3aa 100644 --- a/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/Configuration.java +++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/Configuration.java @@ -11,7 +11,7 @@ public interface Configuration { /** * The constant tenant. */ - public static ThreadLocal tenant = new ThreadLocal(); + public static ThreadLocal tenant = new ThreadLocal<>(); /** * Sets tenant id. diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/ConfigurationChangeListener.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/ConfigurationChangeListener.java index 57814bba44..f7510aef0a 100644 --- a/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/ConfigurationChangeListener.java +++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/ConfigurationChangeListener.java @@ -7,7 +7,6 @@ public interface ConfigurationChangeListener { } public default void notify(String component, String key, Object oldValue, Object newValue) { - System.out.println("HIT"); } public default void notify(String key, Object oldValue, Object newValue) { diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/DynamicConfiguration.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/DynamicConfiguration.java index 428d9ee233..3b64fe71a9 100644 --- a/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/DynamicConfiguration.java +++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/DynamicConfiguration.java @@ -83,14 +83,8 @@ public class DynamicConfiguration { "Only Wrapper classes like Integer, Long, Double, " + "Boolean etc including String are supported."); } - DynamicConfiguration> dynamicConfiguration = new DynamicConfiguration<>(); - dynamicConfiguration.tenant = tenant; - dynamicConfiguration.namespace = namespace; - dynamicConfiguration.key = key; - dynamicConfiguration.clazz = getArrayClass(clazz); - dynamicConfiguration.defaultValue = Arrays.asList(defaultValue); - dynamicConfiguration.configuration = configuration; - return dynamicConfiguration; + return getDynamicConfiguration(tenant, namespace, key, getArrayClass(clazz), + Arrays.asList(defaultValue), configuration); } /** @@ -100,28 +94,38 @@ public class DynamicConfiguration { * @return the array class */ public static Class getArrayClass(Class clazz) { + Class arrayClass = null; switch (clazz.getName()) { case "java.lang.Byte": - return Byte[].class; + arrayClass = Byte[].class; + break; case "java.lang.Short": - return Short[].class; + arrayClass = Short[].class; + break; case "java.lang.Integer": - return Integer[].class; + arrayClass = Integer[].class; + break; case "java.lang.Long": - return Long[].class; + arrayClass = Long[].class; + break; case "java.lang.Float": - return Float[].class; + arrayClass = Float[].class; + break; case "java.lang.Double": - return Double[].class; + arrayClass = Double[].class; + break; case "java.lang.Boolean": - return Boolean[].class; + arrayClass = Boolean[].class; + break; case "java.lang.Character": - return Character[].class; + arrayClass = Character[].class; + break; case "java.lang.String": - return String[].class; + arrayClass = String[].class; + break; default: } - return null; + return arrayClass; } /** diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/Hint.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/Hint.java index c3f54bd183..600c76df52 100644 --- a/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/Hint.java +++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-api/src/main/java/org/openecomp/config/api/Hint.java @@ -4,14 +4,14 @@ public enum Hint { DEFAULT(0b0), LATEST_LOOKUP(0b1), EXTERNAL_LOOKUP(0b10), NODE_SPECIFIC(0b100); - private final int hint; + private final int lookupHint; private Hint(int hnt) { - hint = hnt; + lookupHint = hnt; } public int value() { - return hint; + return lookupHint; } -- cgit 1.2.3-korg