Class IndexItem<A extends Annotation,I>

java.lang.Object
net.java.sezpoz.IndexItem<A,I>
Record Components:
A - the type of annotation being loaded
I - the type of instance being loaded

public final class IndexItem<A extends Annotation,I> extends 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 Details

    • 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<T>) on element (if in fact it has runtime retention, which is encouraged but not required).
      Returns:
      a live or proxy annotation
    • kind

      public ElementType kind()
      Determine what kind of element is annotated.
      Returns:
      one of ElementType.TYPE, ElementType.METHOD, or ElementType.FIELD
    • className

      public 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 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 AnnotatedElement element() throws InstantiationException
      Get the live annotated element.
      Returns:
      a Class, Method, or Field
      Throws:
      InstantiationException - if the class cannot be loaded or there is some other reflective problem
    • instance

      public I instance() throws 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:
      InstantiationException - for the same reasons as element, or if creating the object fails
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object