From c8983a6f979ede3817f060cfa5f93ee40a75fcf4 Mon Sep 17 00:00:00 2001 From: sheetalm Date: Tue, 12 Dec 2017 10:18:53 +0530 Subject: Fixed sonar issues - AbstractComponentFactory Declaring functional interface. Removing unused code. Correct copyright Change-Id: I749929be60eb0e87b6c4b12b30c211bf778af331 Issue-ID: SDC-343 Signed-off-by: sheetalm --- .../core/factory/api/AbstractComponentFactory.java | 34 ++++------------------ 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib') 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 9cd7749f55..102c6db572 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 @@ public abstract class AbstractComponentFactory extends AbstractFactory { InitializationHelper.registerFactoryMapping(registry); } + @FunctionalInterface interface Registry { void register(String factory, String impl); } @@ -55,22 +52,16 @@ public abstract class AbstractComponentFactory extends AbstractFactory { 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 factoryMap = FactoryConfig.getFactoriesMap(); - try { for (Map.Entry entry : factoryMap.entrySet()) { String abstractClassName = entry.getKey(); String concreteTypeName = entry.getValue(); @@ -82,23 +73,8 @@ public abstract class AbstractComponentFactory extends AbstractFactory { .withCategory(ErrorCategory.SYSTEM).build()); } - registry.register(abstractClassName, concreteTypeName); } - } catch (RuntimeException exception) { - throw exception; - } catch (Exception exception) { - throw new RuntimeException(exception); - } - } - - @SuppressWarnings("unchecked") - private static Class unsecureCast(Class cls) { - return (Class) cls; - } - - private static String nameOf(Class clazz) { - return (clazz != null) ? clazz.getName() : "null"; } } -- cgit 1.2.3-korg