public final class AnnotationInstance
extends java.lang.Object
Thread-Safety
This class is immutable and can be shared between threads without safe publication.Modifier and Type | Class and Description |
---|---|
(package private) static class |
AnnotationInstance.InstanceNameComparator |
Modifier and Type | Field and Description |
---|---|
private static AnnotationValue[] |
ANNOTATION_VALUES_TYPE |
(package private) static AnnotationInstance[] |
EMPTY_ARRAY |
private DotName |
name |
(package private) static AnnotationInstance.InstanceNameComparator |
NAME_COMPARATOR |
private AnnotationTarget |
target |
private AnnotationValue[] |
values |
Constructor and Description |
---|
AnnotationInstance(AnnotationInstance instance,
AnnotationTarget target) |
AnnotationInstance(DotName name,
AnnotationTarget target,
AnnotationValue[] values) |
Modifier and Type | Method and Description |
---|---|
static AnnotationInstance |
create(DotName name,
AnnotationTarget target,
AnnotationValue[] values)
Construct a new mock annotation instance.
|
static AnnotationInstance |
create(DotName name,
AnnotationTarget target,
java.util.List<AnnotationValue> values)
Construct a new mock annotation instance.
|
boolean |
equals(java.lang.Object o)
Returns whether or not this annotation instance is equivalent to another instance.
|
int |
hashCode()
Returns a hash code representing this object.
|
DotName |
name()
The name of this annotation in DotName form.
|
(package private) void |
setTarget(AnnotationTarget target) |
AnnotationTarget |
target()
The Java element that this annotation was declared on.
|
java.lang.String |
toString()
Returns a string representation for this annotation instance.
|
java.lang.String |
toString(boolean simple)
Returns an optionally simplified string that represents this annotation instance.
|
AnnotationValue |
value()
Returns the value that is associated with the special default "value"
parameter.
|
AnnotationValue |
value(java.lang.String name)
Returns a value that corresponds with the specified parameter name.
|
(package private) AnnotationValue[] |
valueArray() |
java.util.List<AnnotationValue> |
values()
Returns a list of all parameter values on this annotation instance.
|
java.util.List<AnnotationValue> |
valuesWithDefaults(IndexView index)
Returns a list of all parameter values on this annotation instance,
including default values id defined.
|
AnnotationValue |
valueWithDefault(IndexView index)
Returns the value that is associated with the special default "value"
parameter, also accounting for a value default.
|
AnnotationValue |
valueWithDefault(IndexView index,
java.lang.String name)
Returns a value that corresponds with the specified parameter name,
accounting for its default value.
|
private static final AnnotationValue[] ANNOTATION_VALUES_TYPE
static final AnnotationInstance.InstanceNameComparator NAME_COMPARATOR
static final AnnotationInstance[] EMPTY_ARRAY
private final DotName name
private AnnotationTarget target
private final AnnotationValue[] values
AnnotationInstance(AnnotationInstance instance, AnnotationTarget target)
AnnotationInstance(DotName name, AnnotationTarget target, AnnotationValue[] values)
public static final AnnotationInstance create(DotName name, AnnotationTarget target, AnnotationValue[] values)
name
- the name of the annotation instancetarget
- the thing the annotation is declared onvalues
- the values of this annotation instancepublic static final AnnotationInstance create(DotName name, AnnotationTarget target, java.util.List<AnnotationValue> values)
name
- the name of the annotation instancetarget
- the thing the annotation is declared onvalues
- the values of this annotation instancepublic DotName name()
public AnnotationTarget target()
public AnnotationValue value(java.lang.String name)
name
- the parameter namepublic AnnotationValue value()
public AnnotationValue valueWithDefault(IndexView index, java.lang.String name)
IllegalArgumentException
will be thrown to
prevent non-deterministic results.
If the parameter was not specified by this instance, then the
annotation's ClassInfo
is checked for a default value.
If there is a default, that value is returned. Otherwise null is
returned.
index
- the index containing the defining annotation classname
- the name of the annotation parameterjava.lang.IllegalArgumentException
- if index does not contain the defining
annotation classpublic AnnotationValue valueWithDefault(IndexView index)
IllegalArgumentException
will be
thrown to prevent non-deterministic results.
If the "value" parameter was not specified by this instance, then the
annotation's ClassInfo
is checked for a default value.
If there is a default, that value is returned. Otherwise null is
returned.
index
- the index containing the defining annotation classjava.lang.IllegalArgumentException
- if index does not contain the defining
annotation classpublic java.util.List<AnnotationValue> valuesWithDefaults(IndexView index)
IllegalArgumentException
will be thrown to prevent
non-deterministic results.
The order of this list is undefined.
java.lang.IllegalArgumentException
- if index does not contain the defining
annotation classpublic java.util.List<AnnotationValue> values()
AnnotationValue[] valueArray()
public java.lang.String toString(boolean simple)
simple
- whether to provide a simpler string representationpublic java.lang.String toString()
toString(boolean)
with a value of true.toString
in class java.lang.Object
void setTarget(AnnotationTarget target)
public boolean equals(java.lang.Object o)
AnnotationTarget
instance. The latter restriction
may be softened in future versions.equals
in class java.lang.Object
o
- the annotation instance to compare to.Object.equals(Object)
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()