Class AnnotatedObjectsScanner<T>

java.lang.Object
org.smartparam.engine.annotated.scanner.AnnotatedObjectsScanner<T>
Type Parameters:
T - type of object to instantiate

public class AnnotatedObjectsScanner<T> extends Object
Annotation scanner util supporting SmartParam* annotations. It not only scans for annotated objects, but also instantiates them using hints included in annotation. Annotation should define:
  • value() - to extract unique code of object
  • values() - if same object should be returned multiple times under different names
  • instances() - if object should be instantiated with specific constructor args
Also, if scanned annotation is Sortable, it should define order() method.
Since:
0.1.0
Author:
Adam Dubiel
See Also:
  • Constructor Details

    • AnnotatedObjectsScanner

      public AnnotatedObjectsScanner()
  • Method Details

    • getAnnotatedObjects

      public Map<RepositoryObjectKey,T> getAnnotatedObjects(Class<? extends Annotation> annotationClass, PackageList packagesToScan)

      Scan for classes annotated with given annotation type, instantiate them using hints from annotation and return a map of those objects.

      Might throw AnnotationScannerException if any reflective operation fails.
      Parameters:
      annotationClass - annotation to look for
      packagesToScan - packages to scan
      Returns:
      map of objects
      See Also:
    • getAnnotatedObjectsWithoutName

      public List<T> getAnnotatedObjectsWithoutName(Class<? extends Annotation> annotationClass, PackageList packagesToScan)
      Scan for classes annotated with given annotation and return instances of those objects (instantiated using default constructor).
      Parameters:
      annotationClass - annotation to look for
      packagesToScan - packages to scan
      Returns:
      list of type T objects
    • setReflectionsScanner

      public void setReflectionsScanner(ReflectionsScanner reflectionsScanner)
    • setAnnotatedObjectFactory

      public void setAnnotatedObjectFactory(AnnotatedObjectFactory annotatedObjectFactory)