Reflections reflections = new Reflections("my.project.prefix"); Set<Class<? extends Object>> allClasses = reflections.getSubTypesOf(Object.class);
/** * serialize to a given directory and filename * <p>* it is preferred to specify a designated directory (for example META-INF/reflections), * so that it could be found later much faster using the load method * <p>see the documentation for the save method on the configured {@link org.reflections.serializers.Serializer} */ public File save(final String filename) { return save(filename, configuration.getSerializer()); }
/** recursively get the values stored for the given {@code index} and {@code keys}, not including keys */ public Iterable<String> getAll(String index, String key) { return getAllIncluding(index, get(index, key), new IterableChain<String>()); }
public Set<Class<?>> getAnnotatedClasses() { return reflections.getTypesAnnotatedWith(Api.class); }
/** * get all methods annotated with a given annotation, including annotation member values matching * <p/>depends on MethodAnnotationsScanner configured */ public Set<Method> getMethodsAnnotatedWith(final Annotation annotation) { return filter(getMethodsAnnotatedWith(annotation.annotationType()), withAnnotation(annotation)); }
/** * get all methods annotated with a given annotation, including annotation member values matching * <p/>depends on FieldAnnotationsScanner configured */ public Set<Field> getFieldsAnnotatedWith(final Annotation annotation) { return filter(getFieldsAnnotatedWith(annotation.annotationType()), withAnnotation(annotation)); }
/** get resources relative paths where simple name (key) matches given regular expression * <p>depends on ResourcesScanner configured * <pre>Set<String> xmls = reflections.getResources(".*\\.xml");</pre> */ public Set<String> getResources(final Pattern pattern) { return getResources(new Predicate<String>() { public boolean apply(String input) { return pattern.matcher(input).matches(); } }); }
/** * get all constructors annotated with a given annotation, including annotation member values matching * <p/>depends on MethodAnnotationsScanner configured */ public Set<Constructor> getConstructorsAnnotatedWith(final Annotation annotation) { return filter(getConstructorsAnnotatedWith(annotation.annotationType()), withAnnotation(annotation)); }
/** get the values stored for the given {@code index} and {@code keys} */ public Iterable<String> get(String index, Iterable<String> keys) { Multimap<String, String> mmap = get(index); IterableChain<String> result = new IterableChain<String>(); for (String key : keys) { result.addAll(mmap.get(key)); } return result; }
public Set<Member> getUsages(Reflections reflections) { if (method == null) { return reflections.getConstructorUsage(constructor); } return reflections.getMethodUsage(method); }
Reflections reflections = new Reflections("com.mycompany"); Set<Class<? extends MyInterface>> classes = reflections.getSubTypesOf(MyInterface.class);
/** * get types annotated with a given annotation, both classes and annotations * <p>{@link java.lang.annotation.Inherited} is not honored by default. * <p>when honoring @Inherited, meta-annotation should only effect annotated super classes and its sub types * <p><i>Note that this (@Inherited) meta-annotation type has no effect if the annotated type is used for anything other then a class. * Also, this meta-annotation causes annotations to be inherited only from superclasses; annotations on implemented interfaces have no effect.</i> * <p/>depends on TypeAnnotationsScanner and SubTypesScanner configured */ public Set<Class<?>> getTypesAnnotatedWith(final Class<? extends Annotation> annotation) { return getTypesAnnotatedWith(annotation, false); }
/** get resources relative paths where simple name (key) matches given regular expression * <p>depends on ResourcesScanner configured * <pre>Set<String> xmls = reflections.getResources(".*\\.xml");</pre> */ public Set<String> getResources(final Pattern pattern) { return getResources(new Predicate<String>() { public boolean apply(String input) { return pattern.matcher(input).matches(); } }); }
/** recursively get the values stored for the given {@code index} and {@code keys}, not including keys */ public Iterable<String> getAll(String index, Iterable<String> keys) { return getAllIncluding(index, get(index, keys), new IterableChain<String>()); }
/** * serialize to a given directory and filename * <p>* it is preferred to specify a designated directory (for example META-INF/reflections), * so that it could be found later much faster using the load method * <p>see the documentation for the save method on the configured {@link org.reflections.serializers.Serializer} */ public File save(final String filename) { return save(filename, configuration.getSerializer()); }
/** * get types annotated with a given annotation, both classes and annotations, including annotation member values matching * <p>{@link java.lang.annotation.Inherited} is not honored by default * <p/>depends on TypeAnnotationsScanner configured */ public Set<Class<?>> getTypesAnnotatedWith(final Annotation annotation) { return getTypesAnnotatedWith(annotation, false); }
/** recursively get the values stored for the given {@code index} and {@code keys}, not including keys */ public Iterable<String> getAll(String index, String key) { return getAllIncluding(index, get(index, key), new IterableChain<String>()); }
/** * get types annotated with a given annotation, both classes and annotations, including annotation member values matching * <p>{@link java.lang.annotation.Inherited} is not honored by default * <p/>depends on TypeAnnotationsScanner configured */ public Set<Class<?>> getTypesAnnotatedWith(final Annotation annotation) { return getTypesAnnotatedWith(annotation, false); }
/** recursively get the values stored for the given {@code index} and {@code keys}, not including keys */ public Iterable<String> getAll(String index, Iterable<String> keys) { return getAllIncluding(index, get(index, keys), new IterableChain<String>()); }
/** * get types annotated with a given annotation, both classes and annotations * <p>{@link java.lang.annotation.Inherited} is not honored by default. * <p>when honoring @Inherited, meta-annotation should only effect annotated super classes and its sub types * <p><i>Note that this (@Inherited) meta-annotation type has no effect if the annotated type is used for anything other then a class. * Also, this meta-annotation causes annotations to be inherited only from superclasses; annotations on implemented interfaces have no effect.</i> * <p/>depends on TypeAnnotationsScanner and SubTypesScanner configured */ public Set<Class<?>> getTypesAnnotatedWith(final Class<? extends Annotation> annotation) { return getTypesAnnotatedWith(annotation, false); }