X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Futil%2FInterfacesHelper.java;fp=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Futil%2FInterfacesHelper.java;h=059ba45ec9b79956fa4a3f07a0adad98888d6a3c;hp=8538e3f84d62daf7e216352808743c1bfe2c78f9;hb=2b78ca93f44c372fd72927db6cbd65f5d8387b49;hpb=c0e813ca83ce80d5f3fb340175ddaecd780c6aea diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelper.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelper.java index 8538e3f84d..059ba45ec9 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelper.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -26,8 +26,7 @@ public final class InterfacesHelper { public static Set> getAllInterfaces(Class clazz) { if (clazz.isInterface()) { - throw new IllegalArgumentException(clazz - + " should not be an interface"); + throw new IllegalArgumentException(clazz + " should not be an interface"); } // getInterfaces gets interfaces implemented directly by this class Set> toBeInspected = new HashSet<>(); @@ -48,7 +47,7 @@ public final class InterfacesHelper { Iterator> iterator = interfaces.iterator(); Class ifc = iterator.next(); iterator.remove(); - if (!ifc.isInterface()) { + if (!ifc.isInterface()) { throw new IllegalArgumentException(ifc + " should be an interface"); } interfaces.addAll(Arrays.asList(ifc.getInterfaces())); @@ -59,9 +58,12 @@ public final class InterfacesHelper { /** * Get interfaces that this class is derived from that are JMX interfaces. + * + * @param configBeanClass + * config bean class + * @return set containing classes */ - public static Set> getMXInterfaces( - final Class configBeanClass) { + public static Set> getMXInterfaces(final Class configBeanClass) { Set> allInterfaces = getAllInterfaces(configBeanClass); Set> result = new HashSet<>(); for (Class clazz : allInterfaces) { @@ -76,15 +78,17 @@ public final class InterfacesHelper { * Get all implemented interfaces that have * {@link org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation} * annotation. + * + * @param configBeanClass + * config bean class + * @return set containing classes */ - public static Set> getServiceInterfaces( - final Class configBeanClass) { + public static Set> getServiceInterfaces(final Class configBeanClass) { Set> allInterfaces = getAllInterfaces(configBeanClass); Set> result = new HashSet<>(); for (Class clazz : allInterfaces) { if (AbstractServiceInterface.class.isAssignableFrom(clazz)) { - ServiceInterfaceAnnotation annotation = clazz - .getAnnotation(ServiceInterfaceAnnotation.class); + ServiceInterfaceAnnotation annotation = clazz.getAnnotation(ServiceInterfaceAnnotation.class); if (annotation != null) { result.add(clazz); } @@ -93,52 +97,58 @@ public final class InterfacesHelper { return result; } - public static Set> getAllAbstractServiceClasses(final Class configBeanClass) { + public static Set> getAllAbstractServiceClasses( + final Class configBeanClass) { Set> foundGeneratedSIClasses = new HashSet<>(); for (Class clazz : getAllInterfaces(configBeanClass)) { - if (AbstractServiceInterface.class.isAssignableFrom(clazz) && !AbstractServiceInterface.class.equals(clazz)) { + if (AbstractServiceInterface.class.isAssignableFrom(clazz) + && !AbstractServiceInterface.class.equals(clazz)) { foundGeneratedSIClasses.add((Class) clazz); } } return getAllAbstractServiceInterfaceClasses(foundGeneratedSIClasses); } - /** * Get OSGi registration types under which config bean instance should be * registered. This is specified in * {@link org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation#osgiRegistrationType()} + * + * @param configBeanClass config bean class + * @return set of classes */ - public static Set> getOsgiRegistrationTypes( - final Class configBeanClass) { + public static Set> getOsgiRegistrationTypes(final Class configBeanClass) { Set> serviceInterfaces = getServiceInterfaces(configBeanClass); Set> result = new HashSet<>(); for (Class clazz : serviceInterfaces) { - ServiceInterfaceAnnotation annotation = clazz - .getAnnotation(ServiceInterfaceAnnotation.class); + ServiceInterfaceAnnotation annotation = clazz.getAnnotation(ServiceInterfaceAnnotation.class); result.add(annotation.osgiRegistrationType()); } return result; } public static Set getQNames(final Set siAnnotations) { - Set qNames = new HashSet<>(); - for (ServiceInterfaceAnnotation sia: siAnnotations) { - qNames.add(sia.value()); + Set names = new HashSet<>(); + for (ServiceInterfaceAnnotation sia : siAnnotations) { + names.add(sia.value()); } - return ImmutableSet.copyOf(qNames); + return ImmutableSet.copyOf(names); } public static Set getServiceInterfaceAnnotations(final ModuleFactory factory) { - Set> implementedServiceIntefaces = Collections.unmodifiableSet(factory.getImplementedServiceIntefaces()); + Set> implementedServiceIntefaces = Collections + .unmodifiableSet(factory.getImplementedServiceIntefaces()); return getServiceInterfaceAnnotations(implementedServiceIntefaces); } - private static Set getServiceInterfaceAnnotations(final Set> implementedServiceIntefaces) { - Set> inspected = getAllAbstractServiceInterfaceClasses(implementedServiceIntefaces); + private static Set getServiceInterfaceAnnotations( + final Set> implementedServiceIntefaces) { + Set> inspected = getAllAbstractServiceInterfaceClasses( + implementedServiceIntefaces); Set result = new HashSet<>(); - // SIs can form hierarchies, inspect superclass until it does not extend AbstractSI + // SIs can form hierarchies, inspect superclass until it does not extend + // AbstractSI for (Class clazz : inspected) { ServiceInterfaceAnnotation annotation = clazz.getAnnotation(ServiceInterfaceAnnotation.class); if (annotation != null) { @@ -153,12 +163,10 @@ public final class InterfacesHelper { Set> allInterfaces = getAllSuperInterfaces(directlyImplementedAbstractSIs); Set> result = new HashSet<>(); - for(Class ifc: allInterfaces){ - if (AbstractServiceInterface.class.isAssignableFrom(ifc) && - !ifc.equals(AbstractServiceInterface.class)) { + for (Class ifc : allInterfaces) { + if (AbstractServiceInterface.class.isAssignableFrom(ifc) && !ifc.equals(AbstractServiceInterface.class)) { result.add((Class) ifc); } - } return result; }