Fixed few sonar warnings.
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / util / InterfacesHelper.java
index 5cb1513d9cfa037448d24937e30dfe0ac9bc5a95..8538e3f84d62daf7e216352808743c1bfe2c78f9 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.config.manager.impl.util;
 
+import com.google.common.collect.ImmutableSet;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
@@ -18,7 +19,7 @@ import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnota
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 
-public class InterfacesHelper {
+public final class InterfacesHelper {
 
     private InterfacesHelper() {
     }
@@ -30,7 +31,7 @@ public class InterfacesHelper {
         }
         // getInterfaces gets interfaces implemented directly by this class
         Set<Class<?>> toBeInspected = new HashSet<>();
-        while (clazz.equals(Object.class) == false) {
+        while (!clazz.equals(Object.class)) {
             toBeInspected.addAll(Arrays.asList(clazz.getInterfaces()));
             // get parent class
             clazz = clazz.getSuperclass();
@@ -47,7 +48,7 @@ public class InterfacesHelper {
             Iterator<Class<?>> iterator = interfaces.iterator();
             Class<?> ifc = iterator.next();
             iterator.remove();
-            if (ifc.isInterface() == false)  {
+            if (!ifc.isInterface())  {
                 throw new IllegalArgumentException(ifc + " should be an interface");
             }
             interfaces.addAll(Arrays.asList(ifc.getInterfaces()));
@@ -96,7 +97,7 @@ public class InterfacesHelper {
 
         Set<Class<? extends AbstractServiceInterface>> foundGeneratedSIClasses = new HashSet<>();
         for (Class<?> clazz : getAllInterfaces(configBeanClass)) {
-            if (AbstractServiceInterface.class.isAssignableFrom(clazz) && AbstractServiceInterface.class.equals(clazz) == false) {
+            if (AbstractServiceInterface.class.isAssignableFrom(clazz) && !AbstractServiceInterface.class.equals(clazz)) {
                 foundGeneratedSIClasses.add((Class<? extends AbstractServiceInterface>) clazz);
             }
         }
@@ -126,7 +127,7 @@ public class InterfacesHelper {
         for (ServiceInterfaceAnnotation sia: siAnnotations) {
             qNames.add(sia.value());
         }
-        return Collections.unmodifiableSet(qNames);
+        return ImmutableSet.copyOf(qNames);
     }
 
     public static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(final ModuleFactory factory) {
@@ -154,7 +155,7 @@ public class InterfacesHelper {
         Set<Class<? extends AbstractServiceInterface>> result = new HashSet<>();
         for(Class<?> ifc: allInterfaces){
             if (AbstractServiceInterface.class.isAssignableFrom(ifc) &&
-                    ifc.equals(AbstractServiceInterface.class) == false) {
+                    !ifc.equals(AbstractServiceInterface.class)) {
                 result.add((Class<? extends AbstractServiceInterface>) ifc);
             }