public final class AnnotationValues
extends java.lang.Object
AnnotationValue instances.| Modifier and Type | Method and Description |
|---|---|
static com.google.common.base.Equivalence<javax.lang.model.element.AnnotationValue> |
equivalence()
Returns an
Equivalence for AnnotationValue as annotation values may
contain AnnotationMirror instances some of whose implementations delegate
equality tests to Object.equals(java.lang.Object) whereas the documentation explicitly states
that instance/reference equality is not the proper test. |
static javax.lang.model.element.AnnotationMirror |
getAnnotationMirror(javax.lang.model.element.AnnotationValue value)
Returns the value as an AnnotationMirror.
|
static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror> |
getAnnotationMirrors(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of annotations.
|
static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationValue> |
getAnnotationValues(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of
AnnotationValues. |
static boolean |
getBoolean(javax.lang.model.element.AnnotationValue value)
Returns the value as a boolean.
|
static com.google.common.collect.ImmutableList<java.lang.Boolean> |
getBooleans(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of booleans.
|
static byte |
getByte(javax.lang.model.element.AnnotationValue value)
Returns the value as a byte.
|
static com.google.common.collect.ImmutableList<java.lang.Byte> |
getBytes(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of bytes.
|
static char |
getChar(javax.lang.model.element.AnnotationValue value)
Returns the value as a char.
|
static com.google.common.collect.ImmutableList<java.lang.Character> |
getChars(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of characters.
|
static double |
getDouble(javax.lang.model.element.AnnotationValue value)
Returns the value as a double.
|
static com.google.common.collect.ImmutableList<java.lang.Double> |
getDoubles(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of doubles.
|
static javax.lang.model.element.VariableElement |
getEnum(javax.lang.model.element.AnnotationValue value)
Returns the value as a VariableElement.
|
static com.google.common.collect.ImmutableList<javax.lang.model.element.VariableElement> |
getEnums(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of enums.
|
static float |
getFloat(javax.lang.model.element.AnnotationValue value)
Returns the value as a float.
|
static com.google.common.collect.ImmutableList<java.lang.Float> |
getFloats(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of floats.
|
static int |
getInt(javax.lang.model.element.AnnotationValue value)
Returns the value as an int.
|
static com.google.common.collect.ImmutableList<java.lang.Integer> |
getInts(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of integers.
|
static long |
getLong(javax.lang.model.element.AnnotationValue value)
Returns the value as a long.
|
static com.google.common.collect.ImmutableList<java.lang.Long> |
getLongs(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of longs.
|
static short |
getShort(javax.lang.model.element.AnnotationValue value)
Returns the value as a short.
|
static com.google.common.collect.ImmutableList<java.lang.Short> |
getShorts(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of shorts.
|
static java.lang.String |
getString(javax.lang.model.element.AnnotationValue value)
Returns the value as a string.
|
static com.google.common.collect.ImmutableList<java.lang.String> |
getStrings(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of strings.
|
static javax.lang.model.type.DeclaredType |
getTypeMirror(javax.lang.model.element.AnnotationValue value)
Returns the value as a class.
|
static com.google.common.collect.ImmutableList<javax.lang.model.type.DeclaredType> |
getTypeMirrors(javax.lang.model.element.AnnotationValue value)
Returns the value as a list of classes.
|
static java.lang.String |
toString(javax.lang.model.element.AnnotationValue annotationValue)
Returns a string representation of the given annotation value, suitable for inclusion in a Java
source file as part of an annotation.
|
public static com.google.common.base.Equivalence<javax.lang.model.element.AnnotationValue> equivalence()
Equivalence for AnnotationValue as annotation values may
contain AnnotationMirror instances some of whose implementations delegate
equality tests to Object.equals(java.lang.Object) whereas the documentation explicitly states
that instance/reference equality is not the proper test.AnnotationMirrors.equivalence()public static javax.lang.model.type.DeclaredType getTypeMirror(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not a class.public static javax.lang.model.element.AnnotationMirror getAnnotationMirror(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an annotation.public static javax.lang.model.element.VariableElement getEnum(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an enum.public static java.lang.String getString(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not a string.public static int getInt(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an int.public static long getLong(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not a long.public static byte getByte(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not a byte.public static short getShort(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not a short.public static float getFloat(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not a float.public static double getDouble(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not a double.public static boolean getBoolean(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not a boolean.public static char getChar(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not a char.public static com.google.common.collect.ImmutableList<javax.lang.model.type.DeclaredType> getTypeMirrors(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of classes.public static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationMirror> getAnnotationMirrors(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value if not an array of annotations.public static com.google.common.collect.ImmutableList<javax.lang.model.element.VariableElement> getEnums(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of enums.public static com.google.common.collect.ImmutableList<java.lang.String> getStrings(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of strings.public static com.google.common.collect.ImmutableList<java.lang.Integer> getInts(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of ints.public static com.google.common.collect.ImmutableList<java.lang.Long> getLongs(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of longs.public static com.google.common.collect.ImmutableList<java.lang.Byte> getBytes(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of bytes.public static com.google.common.collect.ImmutableList<java.lang.Short> getShorts(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of shorts.public static com.google.common.collect.ImmutableList<java.lang.Float> getFloats(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of floats.public static com.google.common.collect.ImmutableList<java.lang.Double> getDoubles(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of doubles.public static com.google.common.collect.ImmutableList<java.lang.Boolean> getBooleans(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of booleans.public static com.google.common.collect.ImmutableList<java.lang.Character> getChars(javax.lang.model.element.AnnotationValue value)
java.lang.IllegalArgumentException - if the value is not an array of chars.public static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationValue> getAnnotationValues(javax.lang.model.element.AnnotationValue value)
AnnotationValues.java.lang.IllegalArgumentException - if the value is not an array.public static java.lang.String toString(javax.lang.model.element.AnnotationValue annotationValue)
annotationValue represents the
string unchecked in the annotation @SuppressWarnings("unchecked"), this method
will return the string "unchecked", which you can then use as part of an annotation
being generated.
For all annotation values other than nested annotations, the returned string can also be used to initialize a variable of the appropriate type.
Fully qualified names are used for types in annotations, class literals, and enum constants, ensuring that the source form will compile without requiring additional imports.
Copyright © 2021 Google LLC. All Rights Reserved.