Package net.java.sezpoz
Class Index<A extends java.lang.annotation.Annotation,I>
- java.lang.Object
-
- net.java.sezpoz.Index<A,I>
-
- All Implemented Interfaces:
java.lang.Iterable<IndexItem<A,I>>
public final class Index<A extends java.lang.annotation.Annotation,I> extends java.lang.Object implements java.lang.Iterable<IndexItem<A,I>>
Represents an index of a single annotation. Indices are not automatically cached (but reading them should be pretty cheap anyway).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Iterator<IndexItem<A,I>>iterator()Find all items in the index.static <A extends java.lang.annotation.Annotation,I>
Index<A,I>load(java.lang.Class<A> annotation, java.lang.Class<I> instanceType)Load an index for a given annotation type.static <A extends java.lang.annotation.Annotation,I>
Index<A,I>load(java.lang.Class<A> annotation, java.lang.Class<I> instanceType, java.lang.ClassLoader loader)Load an index for a given annotation type.
-
-
-
Method Detail
-
load
public static <A extends java.lang.annotation.Annotation,I> Index<A,I> load(java.lang.Class<A> annotation, java.lang.Class<I> instanceType) throws java.lang.IllegalArgumentException
Load an index for a given annotation type. Uses the thread's context class loader to find the index and load annotated classes.- Parameters:
annotation- the type of annotation to findinstanceType- the type of instance to be created (useVoidif all instances will be null)- Returns:
- an index of all elements known to be annotated with it
- Throws:
java.lang.IllegalArgumentException- if the annotation type is not marked withIndexableor the instance type is not equal to or a supertype of the annotation's actualIndexable.type()
-
load
public static <A extends java.lang.annotation.Annotation,I> Index<A,I> load(java.lang.Class<A> annotation, java.lang.Class<I> instanceType, java.lang.ClassLoader loader) throws java.lang.IllegalArgumentException
Load an index for a given annotation type.- Parameters:
annotation- the type of annotation to findinstanceType- the type of instance to be created (useVoidif all instances will be null)loader- a class loader in which to find the index and any annotated classes- Returns:
- an index of all elements known to be annotated with it
- Throws:
java.lang.IllegalArgumentException- if the annotation type is not marked withIndexableor the instance type is not equal to or a supertype of the annotation's actualIndexable.type()
-
iterator
public java.util.Iterator<IndexItem<A,I>> iterator()
Find all items in the index. Calls to iterator methods may fail withIndexErroras the index is parsed lazily.- Specified by:
iteratorin interfacejava.lang.Iterable<A extends java.lang.annotation.Annotation>- Returns:
- an iterator over items in the index
-
-