Fixed sonar issues - AbstractComponentFactory
Declaring functional interface. Removing unused code. Correct copyright
Change-Id: I749929be60eb0e87b6c4b12b30c211bf778af331
Issue-ID: SDC-343
Signed-off-by: sheetalm <sheetal.mudholkar@amdocs.com>
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java
index 9cd7749..102c6db 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java
@@ -1,9 +1,6 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2017 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,7 +12,6 @@
* 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.core.factory.api;
@@ -36,6 +32,7 @@
InitializationHelper.registerFactoryMapping(registry);
}
+ @FunctionalInterface
interface Registry {
void register(String factory, String impl);
}
@@ -55,22 +52,16 @@
private InitializationHelper() {
}
- static synchronized boolean registerFactoryMapping(Registry registry) {
-
- boolean done = !isRegistered;
-
+ static synchronized void registerFactoryMapping(Registry registry) {
if (!isRegistered) {
registerFactoryMappingImpl(registry);
isRegistered = true;
}
-
- return done;
}
private static void registerFactoryMappingImpl(Registry registry) {
Map<String, String> factoryMap = FactoryConfig.getFactoriesMap();
- try {
for (Map.Entry<String, String> entry : factoryMap.entrySet()) {
String abstractClassName = entry.getKey();
String concreteTypeName = entry.getValue();
@@ -82,23 +73,8 @@
.withCategory(ErrorCategory.SYSTEM).build());
}
-
registry.register(abstractClassName, concreteTypeName);
}
- } catch (RuntimeException exception) {
- throw exception;
- } catch (Exception exception) {
- throw new RuntimeException(exception);
- }
- }
-
- @SuppressWarnings("unchecked")
- private static <T> Class<T> unsecureCast(Class<?> cls) {
- return (Class<T>) cls;
- }
-
- private static String nameOf(Class<?> clazz) {
- return (clazz != null) ? clazz.getName() : "null";
}
}