public class AnnotationFinder extends java.lang.Object implements IAnnotationFinder
Modifier and Type | Class and Description |
---|---|
class |
AnnotationFinder.Annotatable |
class |
AnnotationFinder.AnnotationInfo |
class |
AnnotationFinder.ClassInfo |
class |
AnnotationFinder.FieldInfo |
static interface |
AnnotationFinder.Info |
class |
AnnotationFinder.InfoBuildingVisitor |
class |
AnnotationFinder.MethodInfo |
class |
AnnotationFinder.PackageInfo |
class |
AnnotationFinder.ParameterInfo |
class |
AnnotationFinder.SubArchive |
Modifier and Type | Field and Description |
---|---|
private static boolean |
ALLOW_LAZY_LINKING |
protected java.util.Map<java.lang.String,java.util.List<AnnotationFinder.Info>> |
annotated |
private Archive |
archive |
private static int |
ASM_FLAGS |
private boolean |
checkRuntimeAnnotation |
private java.util.List<java.lang.String> |
classesNotLoaded |
protected java.util.Map<java.lang.String,AnnotationFinder.ClassInfo> |
classInfos |
private boolean |
linking |
private java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> |
metaroots |
protected java.util.Map<java.lang.String,AnnotationFinder.ClassInfo> |
originalInfos |
Modifier | Constructor and Description |
---|---|
private |
AnnotationFinder(AnnotationFinder parent,
java.lang.Iterable<java.lang.String> classNames) |
|
AnnotationFinder(Archive archive) |
|
AnnotationFinder(Archive archive,
boolean checkRuntimeAnnotation) |
Modifier and Type | Method and Description |
---|---|
private <T> java.util.List<java.lang.Class<? extends T>> |
_findSubclasses(java.lang.Class<T> clazz) |
protected boolean |
cleanOnNaked() |
private java.util.List<AnnotationFinder.ClassInfo> |
collectImplementations(java.lang.String interfaceName) |
AnnotationFinder |
enableFindImplementations() |
AnnotationFinder |
enableFindSubclasses() |
AnnotationFinder |
enableMetaAnnotations() |
java.util.List<java.lang.Class<?>> |
findAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
java.util.List<Parameter<java.lang.reflect.Constructor<?>>> |
findAnnotatedConstructorParameters(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
java.util.List<java.lang.reflect.Constructor> |
findAnnotatedConstructors(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
java.util.List<java.lang.reflect.Field> |
findAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
java.util.List<Parameter<java.lang.reflect.Method>> |
findAnnotatedMethodParameters(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
java.util.List<java.lang.reflect.Method> |
findAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
java.util.List<java.lang.Package> |
findAnnotatedPackages(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
java.util.List<java.lang.Class<?>> |
findClassesInPackage(java.lang.String packageName,
boolean recursive) |
<T> java.util.List<java.lang.Class<? extends T>> |
findImplementations(java.lang.Class<T> clazz) |
java.util.List<java.lang.Class<?>> |
findInheritedAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Naive implementation - works extremelly slow O(n^3)
|
java.util.List<Annotated<java.lang.Class<?>>> |
findMetaAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
private java.util.Set<java.lang.Class<?>> |
findMetaAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation,
java.util.Set<java.lang.Class<?>> classes) |
java.util.List<Annotated<java.lang.reflect.Field>> |
findMetaAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
private java.util.Set<java.lang.reflect.Field> |
findMetaAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation,
java.util.Set<java.lang.reflect.Field> fields,
java.util.Set<java.lang.String> seen) |
java.util.List<Annotated<java.lang.reflect.Method>> |
findMetaAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
private java.util.Set<java.lang.reflect.Method> |
findMetaAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation,
java.util.Set<java.lang.reflect.Method> methods,
java.util.Set<java.lang.String> seen) |
private <T> void |
findSubclasses(AnnotationFinder.ClassInfo classInfo,
java.util.List<java.lang.Class<? extends T>> found,
java.lang.Class<T> clazz) |
<T> java.util.List<java.lang.Class<? extends T>> |
findSubclasses(java.lang.Class<T> clazz) |
java.util.List<java.lang.String> |
getAnnotatedClassNames() |
protected java.util.List<AnnotationFinder.Info> |
getAnnotationInfos(java.lang.String name) |
Archive |
getArchive() |
java.util.List<java.lang.String> |
getClassesNotLoaded()
Returns a list of classes that could not be loaded in last invoked findAnnotated* method.
|
boolean |
hasMetaAnnotations() |
private boolean |
hasName(java.lang.String className,
java.lang.String simpleName) |
private void |
index(AnnotationFinder.AnnotationInfo annotationInfo,
AnnotationFinder.Info info) |
private void |
index(AnnotationFinder.Info i) |
private void |
index(java.util.List<? extends AnnotationFinder.Info> infos) |
protected java.util.List<AnnotationFinder.Info> |
initAnnotationInfos(java.lang.String name) |
boolean |
isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
protected boolean |
isJvm(java.lang.String name) |
private static boolean |
isMetaAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz) |
private boolean |
isMetaRoot(AnnotationFinder.ClassInfo classInfo) |
private static boolean |
isMetatypeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> type) |
private boolean |
isSelfAnnotated(AnnotationFinder.ClassInfo classInfo,
java.lang.String metatype) |
private static boolean |
isSelfAnnotated(java.lang.Class<? extends java.lang.annotation.Annotation> type,
java.lang.String name) |
protected boolean |
isTracked(java.lang.String annotationType) |
AnnotationFinder |
link()
The link() method must be called to successfully use the findSubclasses and findImplementations methods
|
protected void |
linkInterfaces(AnnotationFinder.ClassInfo classInfo) |
private void |
linkMetaAnnotations() |
protected void |
linkParent(AnnotationFinder.ClassInfo classInfo) |
protected java.util.Map<java.lang.String,java.util.List<AnnotationFinder.Info>> |
newAnnotatedMap() |
protected java.util.Map<java.lang.String,AnnotationFinder.ClassInfo> |
newClassInfoMap() |
private void |
readClassDef(AnnotationFinder.ClassInfo info) |
protected void |
readClassDef(java.lang.Class clazz) |
protected void |
readClassDef(java.lang.String className) |
protected void |
readClassDef(java.lang.String className,
java.io.InputStream in) |
private void |
resolveAnnotations(AnnotationFinder parent,
java.util.List<java.lang.String> scanned) |
private void |
resolveAnnotations(java.util.List<java.lang.String> scanned)
Used to support meta annotations
Once the list of classes has been read from the Archive, we
iterate over all the annotations that are used by those classes
and recursively resolve any annotations those annotations use.
|
AnnotationFinder |
select(java.lang.Class<?>... clazz) |
AnnotationFinder |
select(java.lang.Iterable<java.lang.String> clazz) |
AnnotationFinder |
select(java.lang.String... clazz) |
private static boolean |
validTarget(java.lang.Class<? extends java.lang.annotation.Annotation> type) |
private static final int ASM_FLAGS
private static final boolean ALLOW_LAZY_LINKING
private final java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> metaroots
protected final java.util.Map<java.lang.String,java.util.List<AnnotationFinder.Info>> annotated
protected final java.util.Map<java.lang.String,AnnotationFinder.ClassInfo> classInfos
protected final java.util.Map<java.lang.String,AnnotationFinder.ClassInfo> originalInfos
private final java.util.List<java.lang.String> classesNotLoaded
private final Archive archive
private final boolean checkRuntimeAnnotation
private volatile boolean linking
private AnnotationFinder(AnnotationFinder parent, java.lang.Iterable<java.lang.String> classNames)
public AnnotationFinder(Archive archive, boolean checkRuntimeAnnotation)
archive
- checkRuntimeAnnotation
- Has no effect on findMetaAnnotated* methodspublic AnnotationFinder(Archive archive)
protected java.util.Map<java.lang.String,java.util.List<AnnotationFinder.Info>> newAnnotatedMap()
protected java.util.Map<java.lang.String,AnnotationFinder.ClassInfo> newClassInfoMap()
protected boolean cleanOnNaked()
protected boolean isTracked(java.lang.String annotationType)
public boolean hasMetaAnnotations()
private void readClassDef(AnnotationFinder.ClassInfo info)
private void resolveAnnotations(AnnotationFinder parent, java.util.List<java.lang.String> scanned)
private void index(java.util.List<? extends AnnotationFinder.Info> infos)
private void index(AnnotationFinder.Info i)
public java.util.List<java.lang.String> getAnnotatedClassNames()
getAnnotatedClassNames
in interface IAnnotationFinder
public Archive getArchive()
public AnnotationFinder link()
java.io.IOException
public AnnotationFinder enableMetaAnnotations()
public AnnotationFinder enableFindImplementations()
public AnnotationFinder enableFindSubclasses()
private void resolveAnnotations(java.util.List<java.lang.String> scanned)
scanned
- java.lang.ClassNotFoundException
java.io.IOException
private void linkMetaAnnotations()
private boolean isMetaRoot(AnnotationFinder.ClassInfo classInfo)
private boolean isSelfAnnotated(AnnotationFinder.ClassInfo classInfo, java.lang.String metatype)
private boolean hasName(java.lang.String className, java.lang.String simpleName)
protected void linkParent(AnnotationFinder.ClassInfo classInfo)
protected boolean isJvm(java.lang.String name)
protected void linkInterfaces(AnnotationFinder.ClassInfo classInfo)
public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
isAnnotationPresent
in interface IAnnotationFinder
public java.util.List<java.lang.String> getClassesNotLoaded()
getClassesNotLoaded
in interface IAnnotationFinder
public java.util.List<java.lang.Package> findAnnotatedPackages(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
findAnnotatedPackages
in interface IAnnotationFinder
public java.util.List<java.lang.Class<?>> findAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
findAnnotatedClasses
in interface IAnnotationFinder
public java.util.List<Annotated<java.lang.Class<?>>> findMetaAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
findMetaAnnotatedClasses
in interface IAnnotationFinder
private static boolean isMetaAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
private static boolean isMetatypeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> type)
private static boolean isSelfAnnotated(java.lang.Class<? extends java.lang.annotation.Annotation> type, java.lang.String name)
private static boolean validTarget(java.lang.Class<? extends java.lang.annotation.Annotation> type)
private java.util.Set<java.lang.Class<?>> findMetaAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.util.Set<java.lang.Class<?>> classes)
public java.util.List<java.lang.Class<?>> findInheritedAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
findInheritedAnnotatedClasses
in interface IAnnotationFinder
annotation
- public java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
findAnnotatedMethods
in interface IAnnotationFinder
public java.util.List<Parameter<java.lang.reflect.Method>> findAnnotatedMethodParameters(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public java.util.List<Annotated<java.lang.reflect.Method>> findMetaAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
findMetaAnnotatedMethods
in interface IAnnotationFinder
private java.util.Set<java.lang.reflect.Method> findMetaAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.util.Set<java.lang.reflect.Method> methods, java.util.Set<java.lang.String> seen)
public java.util.List<Annotated<java.lang.reflect.Field>> findMetaAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
findMetaAnnotatedFields
in interface IAnnotationFinder
private java.util.Set<java.lang.reflect.Field> findMetaAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.util.Set<java.lang.reflect.Field> fields, java.util.Set<java.lang.String> seen)
public java.util.List<java.lang.reflect.Constructor> findAnnotatedConstructors(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
findAnnotatedConstructors
in interface IAnnotationFinder
public java.util.List<Parameter<java.lang.reflect.Constructor<?>>> findAnnotatedConstructorParameters(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public java.util.List<java.lang.reflect.Field> findAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
findAnnotatedFields
in interface IAnnotationFinder
public java.util.List<java.lang.Class<?>> findClassesInPackage(java.lang.String packageName, boolean recursive)
findClassesInPackage
in interface IAnnotationFinder
public <T> java.util.List<java.lang.Class<? extends T>> findSubclasses(java.lang.Class<T> clazz)
findSubclasses
in interface IAnnotationFinder
private <T> void findSubclasses(AnnotationFinder.ClassInfo classInfo, java.util.List<java.lang.Class<? extends T>> found, java.lang.Class<T> clazz)
private <T> java.util.List<java.lang.Class<? extends T>> _findSubclasses(java.lang.Class<T> clazz)
public <T> java.util.List<java.lang.Class<? extends T>> findImplementations(java.lang.Class<T> clazz)
findImplementations
in interface IAnnotationFinder
private java.util.List<AnnotationFinder.ClassInfo> collectImplementations(java.lang.String interfaceName)
protected java.util.List<AnnotationFinder.Info> getAnnotationInfos(java.lang.String name)
protected java.util.List<AnnotationFinder.Info> initAnnotationInfos(java.lang.String name)
protected void readClassDef(java.lang.String className)
protected void readClassDef(java.lang.String className, java.io.InputStream in) throws java.io.IOException
java.io.IOException
protected void readClassDef(java.lang.Class clazz)
public AnnotationFinder select(java.lang.Class<?>... clazz)
public AnnotationFinder select(java.lang.String... clazz)
public AnnotationFinder select(java.lang.Iterable<java.lang.String> clazz)
private void index(AnnotationFinder.AnnotationInfo annotationInfo, AnnotationFinder.Info info)