/** filter all given {@code elements} with {@code predicates}, if given */ public static <T extends AnnotatedElement> Set<T> getAll(final Set<T> elements, Predicate<? super T>... predicates) { return isEmpty(predicates) ? elements : Sets.newHashSet(Iterables.filter(elements, Predicates.and(predicates))); }
public void close() { Utils.close(jarInputStream); } }
/** 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 all given {@code constructors} usages in methods and constructors * <p>depends on MemberUsageScanner configured */ public Set<Member> getConstructorUsage(Constructor constructor) { return getMembersFromDescriptors(store.get(index(MemberUsageScanner.class), name(constructor))); }
public static Set<Method> getMethodsFromDescriptors(Iterable<String> annotatedWith, ClassLoader... classLoaders) { Set<Method> result = Sets.newHashSet(); for (String annotated : annotatedWith) { if (!isConstructor(annotated)) { Method member = (Method) getMemberFromDescriptor(annotated, classLoaders); if (member != null) result.add(member); } } return result; }
/** get methods with return type match given type */ public Set<Method> getMethodsReturn(Class returnType) { return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), names(returnType)), loaders()); }
/** get all given {@code method} usages in methods and constructors * <p>depends on MemberUsageScanner configured */ public Set<Member> getMethodUsage(Method method) { return getMembersFromDescriptors(store.get(index(MemberUsageScanner.class), name(method))); }
/** 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()); }
if (!isEmpty(methodParameters)) { String[] parameterNames = methodParameters.split(","); List<Class<?>> result = new ArrayList<Class<?>>(parameterNames.length); if (!descriptor.contains("(")) { return aClass.isInterface() ? aClass.getField(memberName) : aClass.getDeclaredField(memberName); } else if (isConstructor(descriptor)) { return aClass.isInterface() ? aClass.getConstructor(parameterTypes) : aClass.getDeclaredConstructor(parameterTypes); } else {
/** 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 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()); }
public static List<String> names(Class<?>... types) { return names(Arrays.asList(types)); }
/** * 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()); }
public static List<String> names(Iterable<Class<?>> types) { List<String> result = new ArrayList<String>(); for (Class<?> type : types) result.add(name(type)); return result; }
/** * 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 parameter names of given {@code constructor} * <p>depends on MethodParameterNamesScanner configured */ public List<String> getConstructorParamNames(Constructor constructor) { Iterable<String> names = store.get(index(MethodParameterNamesScanner.class), Utils.name(constructor)); return !Iterables.isEmpty(names) ? Arrays.asList(Iterables.getOnlyElement(names).split(", ")) : Arrays.<String>asList(); }
/** * 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()); }
public static Set<Member> getMembersFromDescriptors(Iterable<String> values, ClassLoader... classLoaders) { Set<Member> result = Sets.newHashSet(); for (String value : values) { try { result.add(Utils.getMemberFromDescriptor(value, classLoaders)); } catch (ReflectionsException e) { throw new ReflectionsException("Can't resolve member named " + value, e); } } return result; }
/** * 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; }