/** recursively get the values stored for the given {@code index} and {@code keys}, including keys */ private Iterable<String> getAllIncluding(String index, Iterable<String> keys, IterableChain<String> result) { result.addAll(keys); for (String key : keys) { Iterable<String> values = get(index, key); if (values.iterator().hasNext()) { getAllIncluding(index, values, result); } } return result; }
/** get the values stored for the given {@code index} and {@code keys} */ public Iterable<String> get(String index, String... keys) { return get(index, Arrays.asList(keys)); }
/** 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; }
/** get resources relative paths where simple name (key) matches given namePredicate * <p>depends on ResourcesScanner configured * */ public Set<String> getResources(final Predicate<String> namePredicate) { Iterable<String> resources = Iterables.filter(store.get(index(ResourcesScanner.class)).keySet(), namePredicate); return Sets.newHashSet(store.get(index(ResourcesScanner.class), resources)); }
/** get resources relative paths where simple name (key) matches given namePredicate * <p>depends on ResourcesScanner configured * */ public Set<String> getResources(final Predicate<String> namePredicate) { Iterable<String> resources = Iterables.filter(store.get(index(ResourcesScanner.class)).keySet(), namePredicate); return Sets.newHashSet(store.get(index(ResourcesScanner.class), resources)); }
/** 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 parameter names of given {@code method} * <p>depends on MethodParameterNamesScanner configured */ public List<String> getMethodParamNames(Method method) { Iterable<String> names = store.get(index(MethodParameterNamesScanner.class), name(method)); return !Iterables.isEmpty(names) ? Arrays.asList(Iterables.getOnlyElement(names).split(", ")) : Arrays.<String>asList(); }
/** get parameter names of given {@code method} * <p>depends on MethodParameterNamesScanner configured */ public List<String> getMethodParamNames(Method method) { Iterable<String> names = store.get(index(MethodParameterNamesScanner.class), name(method)); return !Iterables.isEmpty(names) ? Arrays.asList(Iterables.getOnlyElement(names).split(", ")) : Arrays.<String>asList(); }
/** * 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 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 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 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))); }
/** 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 all given {@code field} usages in methods and constructors * <p>depends on MemberUsageScanner configured */ public Set<Member> getFieldUsage(Field field) { return getMembersFromDescriptors(store.get(index(MemberUsageScanner.class), name(field))); }
/** 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()); }
/** 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))); }
/** get methods with return type match given type */ public Set<Method> getMethodsReturn(Class returnType) { return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), names(returnType)), loaders()); }