/** * gets all sub types in hierarchy of a given type * <p/>depends on SubTypesScanner configured */ public <T> Set<Class<? extends T>> getSubTypesOf(final Class<T> type) { return Sets.newHashSet(ReflectionUtils.<T>forNames( store.getAll(index(SubTypesScanner.class), Arrays.asList(type.getName())), loaders())); }
/** * get all fields annotated with a given annotation * <p/>depends on FieldAnnotationsScanner configured */ public Set<Field> getFieldsAnnotatedWith(final Class<? extends Annotation> annotation) { final Set<Field> result = Sets.newHashSet(); for (String annotated : store.get(index(FieldAnnotationsScanner.class), annotation.getName())) { result.add(getFieldFromString(annotated, loaders())); } return result; }
/** * gets all sub types in hierarchy of a given type * <p/>depends on SubTypesScanner configured */ public <T> Set<Class<? extends T>> getSubTypesOf(final Class<T> type) { return Sets.newHashSet(ReflectionUtils.<T>forNames( store.getAll(index(SubTypesScanner.class), Arrays.asList(type.getName())), loaders())); }
/** * get all fields annotated with a given annotation * <p/>depends on FieldAnnotationsScanner configured */ public Set<Field> getFieldsAnnotatedWith(final Class<? extends Annotation> annotation) { final Set<Field> result = Sets.newHashSet(); for (String annotated : store.get(index(FieldAnnotationsScanner.class), annotation.getName())) { result.add(getFieldFromString(annotated, loaders())); } return result; }
/** * get types annotated with a given annotation, both classes and annotations * <p>{@link java.lang.annotation.Inherited} is honored according to given honorInherited. * <p>when honoring @Inherited, meta-annotation should only effect annotated super classes and it's sub types * <p>when not honoring @Inherited, meta annotation effects all subtypes, including annotations interfaces and classes * <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, boolean honorInherited) { Iterable<String> annotated = store.get(index(TypeAnnotationsScanner.class), annotation.getName()); Iterable<String> classes = getAllAnnotated(annotated, annotation.isAnnotationPresent(Inherited.class), honorInherited); return Sets.newHashSet(concat(forNames(annotated, loaders()), forNames(classes, loaders()))); }
/** * get types annotated with a given annotation, both classes and annotations, including annotation member values matching * <p>{@link java.lang.annotation.Inherited} is honored according to given honorInherited * <p/>depends on TypeAnnotationsScanner configured */ public Set<Class<?>> getTypesAnnotatedWith(final Annotation annotation, boolean honorInherited) { Iterable<String> annotated = store.get(index(TypeAnnotationsScanner.class), annotation.annotationType().getName()); Iterable<Class<?>> filter = filter(forNames(annotated, loaders()), withAnnotation(annotation)); Iterable<String> classes = getAllAnnotated(names(filter), annotation.annotationType().isAnnotationPresent(Inherited.class), honorInherited); return Sets.newHashSet(concat(filter, forNames(filter(classes, not(in(Sets.newHashSet(annotated)))), loaders()))); }
/** * get types annotated with a given annotation, both classes and annotations, including annotation member values matching * <p>{@link java.lang.annotation.Inherited} is honored according to given honorInherited * <p/>depends on TypeAnnotationsScanner configured */ public Set<Class<?>> getTypesAnnotatedWith(final Annotation annotation, boolean honorInherited) { Iterable<String> annotated = store.get(index(TypeAnnotationsScanner.class), annotation.annotationType().getName()); Iterable<Class<?>> filter = filter(forNames(annotated, loaders()), withAnnotation(annotation)); Iterable<String> classes = getAllAnnotated(names(filter), annotation.annotationType().isAnnotationPresent(Inherited.class), honorInherited); return Sets.newHashSet(concat(filter, forNames(filter(classes, not(in(Sets.newHashSet(annotated)))), loaders()))); }
/** * get all constructors annotated with a given annotation * <p/>depends on MethodAnnotationsScanner configured */ public Set<Constructor> getConstructorsAnnotatedWith(final Class<? extends Annotation> annotation) { Iterable<String> methods = store.get(index(MethodAnnotationsScanner.class), annotation.getName()); return getConstructorsFromDescriptors(methods, loaders()); }
/** * get all methods annotated with a given annotation * <p/>depends on MethodAnnotationsScanner configured */ public Set<Method> getMethodsAnnotatedWith(final Class<? extends Annotation> annotation) { Iterable<String> methods = store.get(index(MethodAnnotationsScanner.class), annotation.getName()); return getMethodsFromDescriptors(methods, loaders()); }
/** get methods with any parameter annotated with given annotation */ public Set<Method> getMethodsWithAnyParamAnnotated(Class<? extends Annotation> annotation) { return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders()); }
/** get constructors with any parameter annotated with given annotation */ public Set<Constructor> getConstructorsWithAnyParamAnnotated(Class<? extends Annotation> annotation) { return getConstructorsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders()); }
/** * get all constructors annotated with a given annotation * <p/>depends on MethodAnnotationsScanner configured */ public Set<Constructor> getConstructorsAnnotatedWith(final Class<? extends Annotation> annotation) { Iterable<String> methods = store.get(index(MethodAnnotationsScanner.class), annotation.getName()); return getConstructorsFromDescriptors(methods, loaders()); }
/** * get all methods annotated with a given annotation * <p/>depends on MethodAnnotationsScanner configured */ public Set<Method> getMethodsAnnotatedWith(final Class<? extends Annotation> annotation) { Iterable<String> methods = store.get(index(MethodAnnotationsScanner.class), annotation.getName()); return getMethodsFromDescriptors(methods, loaders()); }
/** get methods with any parameter annotated with given annotation */ public Set<Method> getMethodsWithAnyParamAnnotated(Class<? extends Annotation> annotation) { return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders()); }
/** get constructors with any parameter annotated with given annotation */ public Set<Constructor> getConstructorsWithAnyParamAnnotated(Class<? extends Annotation> annotation) { return getConstructorsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders()); }
/** get methods with parameter types matching given {@code types}*/ public Set<Method> getMethodsMatchParams(Class<?>... types) { return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), names(types).toString()), loaders()); }
/** get constructors with parameter types matching given {@code types}*/ public Set<Constructor> getConstructorsMatchParams(Class<?>... types) { return getConstructorsFromDescriptors(store.get(index(MethodParameterScanner.class), names(types).toString()), loaders()); }
/** get constructors with parameter types matching given {@code types}*/ public Set<Constructor> getConstructorsMatchParams(Class<?>... types) { return getConstructorsFromDescriptors(store.get(index(MethodParameterScanner.class), names(types).toString()), loaders()); }
/** get methods with parameter types matching given {@code types}*/ public Set<Method> getMethodsMatchParams(Class<?>... types) { return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), names(types).toString()), loaders()); }
/** get methods with return type match given type */ public Set<Method> getMethodsReturn(Class returnType) { return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), names(returnType)), loaders()); }