rachavz / reflections

Automatically exported from code.google.com/p/reflections
Do What The F*ck You Want To Public License
0 stars 0 forks source link

Usage Question #114

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Is there a better way to get all classes that are subtypes of one class and 
annotated with another?

Like so:

Reflections reflections = new Reflections( "projectname" );
Set< Class< ? extends SomeInterface>> both = Reflections.getAll( 
reflections.getSubTypesOf( SomeInterface.class ), Reflections.withAnnotation( 
SomeAnnotation.class ) );

It seems like this isn't quite in line with the API, but I don't see anything 
in the unit test that does multiple predicates.

Original issue reported on code.google.com by javamonk...@gmail.com on 25 May 2012 at 1:40

GoogleCodeExporter commented 9 years ago
FYI - sorry to submit this on the issues page, but I don't see a mailing list, 
open email address or anywhere else to ask questions. Also, I can not set the 
issue type (it is not a defect).

Original comment by javamonk...@gmail.com on 25 May 2012 at 1:41

GoogleCodeExporter commented 9 years ago
the preferred way depends on the size of the metadata and your style...

two options:
- Sets.intersection(reflections.getSubTypesOf(...), 
reflections.getTypesAnnotatedWith(...)) 

- getAll(reflections.getSubTypesOf(...), withAnnotation(...)) 

first uses Reflections indexed metadata (Store), and second uses (also) java 
reflection for the withAnnotation part. 

Original comment by ronm...@gmail.com on 28 May 2012 at 9:05

GoogleCodeExporter commented 9 years ago

Original comment by ronm...@gmail.com on 22 Nov 2013 at 8:51