From 7aa5b935448ed256d61426082c9c6e208ff16f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Thu, 17 Sep 2015 11:09:13 +0200 Subject: [PATCH] Annotations - Missing doc + minor refactoring --- .../ebenoit/ebul/reflection/Annotations.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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; } }