Java Annotation Indexer 1.0.0.Final

org.jboss.jandex
Class AnnotationInstance

java.lang.Object
  extended by org.jboss.jandex.AnnotationInstance

public final class AnnotationInstance
extends Object

An annotation instance represents a specific usage of an annotation on a target. It contains a set of values, as well as a reference to the target itself (e.g. class, field, method, etc).

Thread-Safety

This class is immutable and can be shared between threads without safe publication.

Author:
Jason T. Greene

Method Summary
static AnnotationInstance create(DotName name, AnnotationTarget target, AnnotationValue[] values)
          Construct a new mock annotation instance.
static AnnotationInstance create(DotName name, AnnotationTarget target, List<AnnotationValue> values)
          Construct a new mock annotation instance.
 DotName name()
          The name of this annotation in DotName form.
 AnnotationTarget target()
          The Java element that this annotation was declared on.
 String toString()
           
 AnnotationValue value()
          Returns the value that is associated with the special default "value" parameter.
 AnnotationValue value(String name)
          Returns a value that corresponds with the specified parameter name.
 List<AnnotationValue> values()
          Returns a list of all parameter values on this annotation instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static final AnnotationInstance create(DotName name,
                                              AnnotationTarget target,
                                              AnnotationValue[] values)
Construct a new mock annotation instance. The passed values array will be defensively copied.

Parameters:
name - the name of the annotation instance
target - the thing the annotation is declared on
values - the values of this annotation instance
Returns:
the new mock Annotation Instance

create

public static final AnnotationInstance create(DotName name,
                                              AnnotationTarget target,
                                              List<AnnotationValue> values)
Construct a new mock annotation instance. The passed values list will be defensively copied.

Parameters:
name - the name of the annotation instance
target - the thing the annotation is declared on
values - the values of this annotation instance
Returns:
the new mock Annotation Instance

name

public DotName name()
The name of this annotation in DotName form.

Returns:
the name of this annotation

target

public AnnotationTarget target()
The Java element that this annotation was declared on. This can be a class, a field, a method, or a method parameter. In addition it may be null if this instance is a nested annotation, in which case there is no target.

Returns:
the target this annotation instance refers to

value

public AnnotationValue value(String name)
Returns a value that corresponds with the specified parameter name. If the parameter was not specified by this instance then null is returned. Note that this also applies to a defaulted parameter, which is not recorded in the target class.

Parameters:
name - the parameter name
Returns:
the value of the specified parameter, or null if not provided

value

public AnnotationValue value()
Returns the value that is associated with the special default "value" parameter.

Returns:
the "value" value

values

public List<AnnotationValue> values()
Returns a list of all parameter values on this annotation instance. While random access is allowed, the ordering algorithm of the list should not be relied upon. Although it will be consistent for the life of this instance.

Returns:
the parameter values of this annotation

toString

public String toString()
Overrides:
toString in class Object

Java Annotation Indexer 1.0.0.Final

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.