Package com.peterphi.std.guice.common
Class ClassScanner
java.lang.Object
com.peterphi.std.guice.common.ClassScanner
-
Constructor Summary
ConstructorsConstructorDescriptionClassScanner(org.apache.xbean.finder.AnnotationFinder finder, long constructionTime) Construct a new ClassScanner wrapper around anAnnotationFinder -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.base.Predicate<Class<?>>annotatedWith(Class<? extends Annotation> annotation) getAnnotatedClasses(Class<? extends Annotation> annotation) getAnnotatedClasses(Class<? extends Annotation> annotation, com.google.common.base.Predicate<Class<?>> predicate) getClasses(String pkg, boolean recursive) Find all the classes in a packagegetClasses(String pkg, boolean recursive, com.google.common.base.Predicate<Class<?>> predicate) Find all the classes in a packagelonggetImplementations(Class<T> clazz) Find all implementations of an interface (if an interface is provided) or extensions (if a class is provided)getImplementations(Class<T> clazz, com.google.common.base.Predicate<Class<? extends T>> predicate) Find filtered implementations of an interface (if an interface is provided) or extensions (if a class is provided)getInheritedAnnotatedClasses(Class<? extends Annotation> annotation) getInheritedAnnotatedClasses(Class<? extends Annotation> annotation, com.google.common.base.Predicate<Class<?>> predicate) longgetSiblingClasses(Class<?> clazz, boolean recursive, com.google.common.base.Predicate<Class<?>> predicate) Find all the classes that are siblings of the provided classstatic com.google.common.base.Predicate<Class<?>>static com.google.common.base.Predicate<Class<?>>packagePredicate(com.google.common.base.Predicate<String> packagePredicate)
-
Constructor Details
-
ClassScanner
public ClassScanner(org.apache.xbean.finder.AnnotationFinder finder, long constructionTime) Construct a new ClassScanner wrapper around anAnnotationFinder- Parameters:
finder- the xbeans-finder instance to use for searchesconstructionTime- the time (in ms) taken to construct the associatedAnnotationFinderinstance (to expose for timing data)
-
-
Method Details
-
getConstructionTime
public long getConstructionTime() -
getSearchTime
public long getSearchTime() -
getClasses
public List<Class<?>> getClasses(String pkg, boolean recursive, com.google.common.base.Predicate<Class<?>> predicate) Find all the classes in a package- Parameters:
pkg-recursive-predicate- an optional additional predicate to filter the list against- Returns:
-
getClasses
Find all the classes in a package- Parameters:
pkg-recursive-- Returns:
-
getSiblingClasses
public List<Class<?>> getSiblingClasses(Class<?> clazz, boolean recursive, com.google.common.base.Predicate<Class<?>> predicate) Find all the classes that are siblings of the provided class- Parameters:
clazz- the class in whose package to searchrecursive- if true, search all the child packages of the package containing the classpredicate- an optional additional predicate to filter the list against- Returns:
-
getAnnotatedClasses
public List<Class<?>> getAnnotatedClasses(Class<? extends Annotation> annotation, com.google.common.base.Predicate<Class<?>> predicate) -
getAnnotatedClasses
-
getInheritedAnnotatedClasses
public List<Class<?>> getInheritedAnnotatedClasses(Class<? extends Annotation> annotation, com.google.common.base.Predicate<Class<?>> predicate) -
getInheritedAnnotatedClasses
-
getImplementations
Find all implementations of an interface (if an interface is provided) or extensions (if a class is provided)- Type Parameters:
T-- Parameters:
clazz-- Returns:
-
getImplementations
public <T> List<Class<? extends T>> getImplementations(Class<T> clazz, com.google.common.base.Predicate<Class<? extends T>> predicate) Find filtered implementations of an interface (if an interface is provided) or extensions (if a class is provided)- Type Parameters:
T-- Parameters:
clazz-predicate- the predicate to use to filter the implementations- Returns:
-
annotatedWith
public static com.google.common.base.Predicate<Class<?>> annotatedWith(Class<? extends Annotation> annotation) -
packagePredicate
-
interfaceClass
-