net.java.sezpoz
Class IndexItem<A extends java.lang.annotation.Annotation,I>

java.lang.Object
  extended by net.java.sezpoz.IndexItem<A,I>

public final class IndexItem<A extends java.lang.annotation.Annotation,I>
extends java.lang.Object

One index item. May be associated with a class, method, or field. Caches result of element and instance after first call. Not thread-safe.


Method Summary
 A annotation()
          Get the annotation itself.
 java.lang.String className()
          Get the name of the class which is the annotated element or of which the annotated element is a member.
 java.lang.reflect.AnnotatedElement element()
          Get the live annotated element.
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 I instance()
          Get an instance referred to by the element.
 java.lang.annotation.ElementType kind()
          Determine what kind of element is annotated.
 java.lang.String memberName()
          Get the name of the annotated member element.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

annotation

public A annotation()
Get the annotation itself. A lightweight proxy will be returned which obeys the Annotation contract and should be equal to (but not identical to) the "real" annotation available from AnnotatedElement.getAnnotation(java.lang.Class) on element (if in fact it has runtime retention, which is encouraged but not required).

Returns:
a live or proxy annotation

kind

public java.lang.annotation.ElementType kind()
Determine what kind of element is annotated.

Returns:
one of ElementType.TYPE, ElementType.METHOD, or ElementType.FIELD

className

public java.lang.String className()
Get the name of the class which is the annotated element or of which the annotated element is a member.

Returns:
the class name (format e.g. "x.y.Z$I")

memberName

public java.lang.String memberName()
Get the name of the annotated member element.

Returns:
a method or field name, or null if the annotated element is a class

element

public java.lang.reflect.AnnotatedElement element()
                                           throws java.lang.InstantiationException
Get the live annotated element.

Returns:
a Class, Method, or Field
Throws:
java.lang.InstantiationException - if the class cannot be loaded or there is some other reflective problem

instance

public I instance()
           throws java.lang.InstantiationException
Get an instance referred to by the element. This instance is cached by the item object. The element must always be public.
  1. In case of a class, the class will be instantiated by a public no-argument constructor.
  2. In case of a method, it must be static and have no arguments; it will be called.
  3. In case of a field, it must be static and final; its value will be used.

Returns:
an object guaranteed to be assignable to the Indexable.type() if specified (or may be null, in the case of a method or field)
Throws:
java.lang.InstantiationException - for the same reasons as element, or if creating the object fails

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2011. All Rights Reserved.