Package net.java.sezpoz
Class Index<A extends Annotation,I>
java.lang.Object
net.java.sezpoz.Index<A,I>
- Record Components:
A
- the type of annotation to loadI
- the type of instance which will be created
Represents an index of a single annotation.
Indices are not automatically cached
(but reading them should be pretty cheap anyway).
-
Method Summary
Modifier and TypeMethodDescriptioniterator()
Find all items in the index.static <A extends Annotation,
I>
Index<A, I> Load an index for a given annotation type.static <A extends Annotation,
I>
Index<A, I> load
(Class<A> annotation, Class<I> instanceType, ClassLoader loader) Load an index for a given annotation type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
load
public static <A extends Annotation,I> Index<A,I> load(Class<A> annotation, Class<I> instanceType) throws 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 (useVoid
if all instances will be null)- Returns:
- an index of all elements known to be annotated with it
- Throws:
IllegalArgumentException
- if the annotation type is not marked withIndexable
or the instance type is not equal to or a supertype of the annotation's actualIndexable.type()
-
load
public static <A extends Annotation,I> Index<A,I> load(Class<A> annotation, Class<I> instanceType, ClassLoader loader) throws IllegalArgumentException Load an index for a given annotation type.- Parameters:
annotation
- the type of annotation to findinstanceType
- the type of instance to be created (useVoid
if 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:
IllegalArgumentException
- if the annotation type is not marked withIndexable
or the instance type is not equal to or a supertype of the annotation's actualIndexable.type()
-
iterator
Find all items in the index. Calls to iterator methods may fail withIndexError
as the index is parsed lazily.- Specified by:
iterator
in interfaceIterable<A extends Annotation>
- Returns:
- an iterator over items in the index
-