Issue fix for config subsystem
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / util / InterfacesHelper.java
index 033f7222fcc7fd64103e25336a3b81f669d14adc..4d94c6d2655650ece2f9bcb1a26a3e0b872a7d60 100644 (file)
@@ -21,6 +21,9 @@ import java.util.Set;
 
 public class InterfacesHelper {
 
+    private InterfacesHelper() {
+    }
+
     public static Set<Class<?>> getAllInterfaces(Class<?> clazz) {
         if (clazz.isInterface()) {
             throw new IllegalArgumentException(clazz
@@ -38,17 +41,17 @@ public class InterfacesHelper {
     }
 
     private static Set<Class<?>> getAllSuperInterfaces(Set<Class<?>> ifcs) {
-        ifcs = new HashSet<>(ifcs); // create copy to modify
+        Set<Class<?>> interfaces = new HashSet<>(ifcs); // create copy to modify
         // each interface can extend other interfaces
         Set<Class<?>> result = new HashSet<>();
-        while (ifcs.size() > 0) {
-            Iterator<Class<?>> iterator = ifcs.iterator();
+        while (!interfaces.isEmpty()) {
+            Iterator<Class<?>> iterator = interfaces.iterator();
             Class<?> ifc = iterator.next();
             iterator.remove();
             if (ifc.isInterface() == false)  {
                 throw new IllegalArgumentException(ifc + " should be an interface");
             }
-            ifcs.addAll(Arrays.asList(ifc.getInterfaces()));
+            interfaces.addAll(Arrays.asList(ifc.getInterfaces()));
             result.add(ifc);
         }
         return result;
@@ -109,7 +112,6 @@ public class InterfacesHelper {
      */
     public static Set<Class<?>> getOsgiRegistrationTypes(
             Class<? extends Module> configBeanClass) {
-        // TODO test with service interface hierarchy
         Set<Class<?>> serviceInterfaces = getServiceInterfaces(configBeanClass);
         Set<Class<?>> result = new HashSet<>();
         for (Class<?> clazz : serviceInterfaces) {
@@ -120,6 +122,13 @@ public class InterfacesHelper {
         return result;
     }
 
+    public static Set<String> getQNames(Set<ServiceInterfaceAnnotation> siAnnotations) {
+        Set<String> qNames = new HashSet<>();
+        for (ServiceInterfaceAnnotation sia: siAnnotations) {
+            qNames.add(sia.value());
+        }
+        return Collections.unmodifiableSet(qNames);
+    }
 
     public static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(ModuleFactory factory) {
         Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces = Collections.unmodifiableSet(factory.getImplementedServiceIntefaces());
@@ -136,7 +145,7 @@ public class InterfacesHelper {
                 result.add(annotation);
             }
         }
-        return result;
+        return Collections.unmodifiableSet(result);
     }
 
     static Set<Class<? extends AbstractServiceInterface>> getAllAbstractServiceInterfaceClasses(