/** get fields of given {@code type}, optionally filtered by {@code predicates} */ public static Set<Field> getFields(Class<?> type, Predicate<? super Field>... predicates) { return filter(type.getDeclaredFields(), predicates); }
/** get constructors of given {@code type}, optionally filtered by {@code predicates} */ public static Set<Constructor> getConstructors(Class<?> t, Predicate<? super Constructor>... predicates) { return ReflectionUtils.<Constructor>filter(t.getDeclaredConstructors(), predicates); //explicit needed only for jdk1.5 }
/** get constructors of given {@code type}, optionally filtered by {@code predicates} */ public static Set<Constructor> getConstructors(Class<?> t, Predicate<? super Constructor>... predicates) { return ReflectionUtils.<Constructor>filter(t.getDeclaredConstructors(), predicates); //explicit needed only for jdk1.5 }
/** get methods of given {@code type}, optionally filtered by {@code predicates} */ public static Set<Method> getMethods(Class<?> t, Predicate<? super Method>... predicates) { return filter(t.isInterface() ? t.getMethods() : t.getDeclaredMethods(), predicates); }
/** get methods of given {@code type}, optionally filtered by {@code predicates} */ public static Set<Method> getMethods(Class<?> t, Predicate<? super Method>... predicates) { return filter(t.isInterface() ? t.getMethods() : t.getDeclaredMethods(), predicates); }
/** get annotations of given {@code type}, optionally honorInherited, optionally filtered by {@code predicates} */ public static <T extends AnnotatedElement> Set<Annotation> getAnnotations(T type, Predicate<Annotation>... predicates) { return filter(type.getDeclaredAnnotations(), predicates); }
/** get annotations of given {@code type}, optionally honorInherited, optionally filtered by {@code predicates} */ public static <T extends AnnotatedElement> Set<Annotation> getAnnotations(T type, Predicate<Annotation>... predicates) { return filter(type.getDeclaredAnnotations(), predicates); }
/** get all super types of given {@code type}, including, optionally filtered by {@code predicates} * <p> include {@code Object.class} if {@link #includeObject} is true */ public static Set<Class<?>> getAllSuperTypes(final Class<?> type, Predicate<? super Class<?>>... predicates) { Set<Class<?>> result = Sets.newLinkedHashSet(); if (type != null && (includeObject || !type.equals(Object.class))) { result.add(type); for (Class<?> supertype : getSuperTypes(type)) { result.addAll(getAllSuperTypes(supertype)); } } return filter(result, predicates); }
/** get all super types of given {@code type}, including, optionally filtered by {@code predicates} * <p> include {@code Object.class} if {@link #includeObject} is true */ public static Set<Class<?>> getAllSuperTypes(final Class<?> type, Predicate<? super Class<?>>... predicates) { Set<Class<?>> result = Sets.newLinkedHashSet(); if (type != null && (includeObject || !type.equals(Object.class))) { result.add(type); for (Class<?> supertype : getSuperTypes(type)) { result.addAll(getAllSuperTypes(supertype)); } } return filter(result, predicates); }
/** * 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 constructors with any parameter annotated with given annotation, including annotation member values matching */ public Set<Constructor> getConstructorsWithAnyParamAnnotated(Annotation annotation) { return filter(getConstructorsWithAnyParamAnnotated(annotation.annotationType()), withAnyParameterAnnotation(annotation)); }
/** * 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 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 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 methods with any parameter annotated with given annotation, including annotation member values matching */ public Set<Method> getMethodsWithAnyParamAnnotated(Annotation annotation) { return filter(getMethodsWithAnyParamAnnotated(annotation.annotationType()), withAnyParameterAnnotation(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 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 constructors with any parameter annotated with given annotation, including annotation member values matching */ public Set<Constructor> getConstructorsWithAnyParamAnnotated(Annotation annotation) { return filter(getConstructorsWithAnyParamAnnotated(annotation.annotationType()), withAnyParameterAnnotation(annotation)); }
/** * 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()))); }