X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fdynamicmbean%2FAnnotationsHelper.java;h=fba9844dbfaf9d7fc8cef7ed54e223c73c7431b2;hb=6f9b565103acbc6eae1c50e5ef609241ebc8486e;hp=c4dee3513d6e5bedd9376ddf64f6405c0c76647b;hpb=0a16f37f1baa4a2616e9b7289a445649b4f3132d;p=controller.git diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsHelper.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsHelper.java index c4dee3513d..fba9844dbf 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsHelper.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsHelper.java @@ -7,13 +7,14 @@ */ package org.opendaylight.controller.config.manager.impl.dynamicmbean; -import org.opendaylight.controller.config.api.annotations.Description; - +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.opendaylight.controller.config.api.annotations.Description; public class AnnotationsHelper { @@ -30,9 +31,9 @@ public class AnnotationsHelper { * @return list of found annotations */ static List findMethodAnnotationInSuperClassesAndIfcs( - final Method setter, Class annotationType, - Set> inspectedInterfaces) { - List result = new ArrayList(); + final Method setter, final Class annotationType, + final Set> inspectedInterfaces) { + Builder result = ImmutableSet.builder(); Class inspectedClass = setter.getDeclaringClass(); do { try { @@ -47,7 +48,8 @@ public class AnnotationsHelper { } catch (NoSuchMethodException e) { inspectedClass = Object.class; // no need to go further } - } while (inspectedClass.equals(Object.class) == false); + } while (!inspectedClass.equals(Object.class)); + // inspect interfaces for (Class ifc : inspectedInterfaces) { if (ifc.isInterface() == false) { @@ -64,7 +66,7 @@ public class AnnotationsHelper { } } - return result; + return new ArrayList<>(result.build()); } /** @@ -75,7 +77,7 @@ public class AnnotationsHelper { * @return list of found annotations */ static List findClassAnnotationInSuperClassesAndIfcs( - Class clazz, Class annotationType, Set> interfaces) { + final Class clazz, final Class annotationType, final Set> interfaces) { List result = new ArrayList(); Class declaringClass = clazz; do { @@ -102,7 +104,7 @@ public class AnnotationsHelper { * @return empty string if no annotation is found, or list of descriptions * separated by newline */ - static String aggregateDescriptions(List descriptions) { + static String aggregateDescriptions(final List descriptions) { StringBuilder builder = new StringBuilder(); for (Description d : descriptions) { if (builder.length() != 0) {