diff --git a/src/main/java/info/ebenoit/ebul/reflection/Annotations.java b/src/main/java/info/ebenoit/ebul/reflection/Annotations.java index 9f9145b..9b10050 100644 --- a/src/main/java/info/ebenoit/ebul/reflection/Annotations.java +++ b/src/main/java/info/ebenoit/ebul/reflection/Annotations.java @@ -198,6 +198,15 @@ public final class Annotations } + /** + * Finds all parent classes with a specific annotation + * + * @param klass + * the class to examine + * @param annotation + * the annotation to look for + * @return the list of classes that have the specified annotation amongst the specified class' ancestors + */ public static < T > ArrayList< Class< ? super T > > findParentsWith( final Class< T > klass , final Class< ? extends Annotation > annotation ) { @@ -207,8 +216,19 @@ public final class Annotations } - public static < T > void findParentsWith( ArrayList< Class< ? super T > > output , Class< T > klass , - Class< ? extends Annotation > annotation ) + /** + * Finds all parent classes with a specific annotation + * + * @param output + * the collection to which matching ancestors will be added + * @param klass + * the class to examine + * @param annotation + * the annotation to look for + * @return the collection to which matching ancestors were added + */ + public static < T > Collection< Class< ? super T > > findParentsWith( Collection< Class< ? super T > > output , + Class< T > klass , Class< ? extends Annotation > annotation ) { Class< ? super T > current = klass; while ( current != null ) { @@ -217,6 +237,7 @@ public final class Annotations } current = current.getSuperclass( ); } + return output; } }