Class ClassScanner

java.lang.Object
com.peterphi.std.guice.common.ClassScanner

public class ClassScanner extends Object
  • Constructor Details

    • ClassScanner

      public ClassScanner(org.apache.xbean.finder.AnnotationFinder finder, long constructionTime)
      Construct a new ClassScanner wrapper around an AnnotationFinder
      Parameters:
      finder - the xbeans-finder instance to use for searches
      constructionTime - the time (in ms) taken to construct the associated AnnotationFinder instance (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

      public List<Class<?>> getClasses(String pkg, boolean recursive)
      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 search
      recursive - if true, search all the child packages of the package containing the class
      predicate - 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

      public List<Class<?>> getAnnotatedClasses(Class<? extends Annotation> annotation)
    • getInheritedAnnotatedClasses

      public List<Class<?>> getInheritedAnnotatedClasses(Class<? extends Annotation> annotation, com.google.common.base.Predicate<Class<?>> predicate)
    • getInheritedAnnotatedClasses

      public List<Class<?>> getInheritedAnnotatedClasses(Class<? extends Annotation> annotation)
    • getImplementations

      public <T> List<Class<? extends T>> getImplementations(Class<T> clazz)
      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

      public static com.google.common.base.Predicate<Class<?>> packagePredicate(com.google.common.base.Predicate<String> packagePredicate)
    • interfaceClass

      public static com.google.common.base.Predicate<Class<?>> interfaceClass()