Package com.google.auto.common
Class AnnotationValues
java.lang.Object
com.google.auto.common.AnnotationValues
A utility class for working with
AnnotationValue
instances.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
private static class
private static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final AnnotationValues.ArrayVisitor<AnnotationMirror>
private static final com.google.common.base.Equivalence<AnnotationValue>
private static final AnnotationValues.ArrayVisitor<AnnotationValue>
private static final AnnotationValues.ArrayVisitor<Boolean>
private static final AnnotationValues.ArrayVisitor<Byte>
private static final AnnotationValues.ArrayVisitor<Character>
private static final AnnotationValues.ArrayVisitor<Double>
private static final AnnotationValues.ArrayVisitor<VariableElement>
private static final AnnotationValues.ArrayVisitor<Float>
private static final AnnotationValues.ArrayVisitor<Integer>
private static final AnnotationValues.ArrayVisitor<Long>
private static final AnnotationValues.ArrayVisitor<Short>
private static final AnnotationValues.ArrayVisitor<String>
private static final AnnotationValues.ArrayVisitor<DeclaredType>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.base.Equivalence<AnnotationValue>
Returns anEquivalence
forAnnotationValue
as annotation values may containAnnotationMirror
instances some of whose implementations delegate equality tests toObject.equals(java.lang.Object)
whereas the documentation explicitly states that instance/reference equality is not the proper test.static AnnotationMirror
Returns the value as an AnnotationMirror.static com.google.common.collect.ImmutableList<AnnotationMirror>
Returns the value as a list of annotations.static com.google.common.collect.ImmutableList<AnnotationValue>
Returns the value as a list ofAnnotationValue
s.static boolean
getBoolean
(AnnotationValue value) Returns the value as a boolean.static com.google.common.collect.ImmutableList<Boolean>
getBooleans
(AnnotationValue value) Returns the value as a list of booleans.static byte
getByte
(AnnotationValue value) Returns the value as a byte.static com.google.common.collect.ImmutableList<Byte>
getBytes
(AnnotationValue value) Returns the value as a list of bytes.static char
getChar
(AnnotationValue value) Returns the value as a char.static com.google.common.collect.ImmutableList<Character>
getChars
(AnnotationValue value) Returns the value as a list of characters.static double
getDouble
(AnnotationValue value) Returns the value as a double.static com.google.common.collect.ImmutableList<Double>
getDoubles
(AnnotationValue value) Returns the value as a list of doubles.static VariableElement
getEnum
(AnnotationValue value) Returns the value as a VariableElement.static com.google.common.collect.ImmutableList<VariableElement>
getEnums
(AnnotationValue value) Returns the value as a list of enums.static float
getFloat
(AnnotationValue value) Returns the value as a float.static com.google.common.collect.ImmutableList<Float>
getFloats
(AnnotationValue value) Returns the value as a list of floats.static int
getInt
(AnnotationValue value) Returns the value as an int.static com.google.common.collect.ImmutableList<Integer>
getInts
(AnnotationValue value) Returns the value as a list of integers.static long
getLong
(AnnotationValue value) Returns the value as a long.static com.google.common.collect.ImmutableList<Long>
getLongs
(AnnotationValue value) Returns the value as a list of longs.static short
getShort
(AnnotationValue value) Returns the value as a short.static com.google.common.collect.ImmutableList<Short>
getShorts
(AnnotationValue value) Returns the value as a list of shorts.static String
getString
(AnnotationValue value) Returns the value as a string.static com.google.common.collect.ImmutableList<String>
getStrings
(AnnotationValue value) Returns the value as a list of strings.static DeclaredType
getTypeMirror
(AnnotationValue value) Returns the value as a class.static com.google.common.collect.ImmutableList<DeclaredType>
getTypeMirrors
(AnnotationValue value) Returns the value as a list of classes.private static <T> T
valueOfType
(AnnotationValue annotationValue, Class<T> type)
-
Field Details
-
ANNOTATION_VALUE_EQUIVALENCE
private static final com.google.common.base.Equivalence<AnnotationValue> ANNOTATION_VALUE_EQUIVALENCE -
TYPE_MIRRORS_VISITOR
-
ANNOTATION_MIRRORS_VISITOR
-
ENUMS_VISITOR
-
STRINGS_VISITOR
-
INTS_VISITOR
-
LONGS_VISITOR
-
BYTES_VISITOR
-
SHORTS_VISITOR
-
FLOATS_VISITOR
-
DOUBLES_VISITOR
-
BOOLEANS_VISITOR
-
CHARS_VISITOR
-
ANNOTATION_VALUES_VISITOR
-
-
Constructor Details
-
AnnotationValues
private AnnotationValues()
-
-
Method Details
-
equivalence
Returns anEquivalence
forAnnotationValue
as annotation values may containAnnotationMirror
instances some of whose implementations delegate equality tests toObject.equals(java.lang.Object)
whereas the documentation explicitly states that instance/reference equality is not the proper test.- See Also:
-
getTypeMirror
Returns the value as a class.- Throws:
IllegalArgumentException
- if the value is not a class.
-
getAnnotationMirror
Returns the value as an AnnotationMirror.- Throws:
IllegalArgumentException
- if the value is not an annotation.
-
getEnum
Returns the value as a VariableElement.- Throws:
IllegalArgumentException
- if the value is not an enum.
-
valueOfType
-
getString
Returns the value as a string.- Throws:
IllegalArgumentException
- if the value is not a string.
-
getInt
Returns the value as an int.- Throws:
IllegalArgumentException
- if the value is not an int.
-
getLong
Returns the value as a long.- Throws:
IllegalArgumentException
- if the value is not a long.
-
getByte
Returns the value as a byte.- Throws:
IllegalArgumentException
- if the value is not a byte.
-
getShort
Returns the value as a short.- Throws:
IllegalArgumentException
- if the value is not a short.
-
getFloat
Returns the value as a float.- Throws:
IllegalArgumentException
- if the value is not a float.
-
getDouble
Returns the value as a double.- Throws:
IllegalArgumentException
- if the value is not a double.
-
getBoolean
Returns the value as a boolean.- Throws:
IllegalArgumentException
- if the value is not a boolean.
-
getChar
Returns the value as a char.- Throws:
IllegalArgumentException
- if the value is not a char.
-
getTypeMirrors
public static com.google.common.collect.ImmutableList<DeclaredType> getTypeMirrors(AnnotationValue value) Returns the value as a list of classes.- Throws:
IllegalArgumentException
- if the value is not an array of classes.
-
getAnnotationMirrors
public static com.google.common.collect.ImmutableList<AnnotationMirror> getAnnotationMirrors(AnnotationValue value) Returns the value as a list of annotations.- Throws:
IllegalArgumentException
- if the value if not an array of annotations.
-
getEnums
public static com.google.common.collect.ImmutableList<VariableElement> getEnums(AnnotationValue value) Returns the value as a list of enums.- Throws:
IllegalArgumentException
- if the value is not an array of enums.
-
getStrings
Returns the value as a list of strings.- Throws:
IllegalArgumentException
- if the value is not an array of strings.
-
getInts
Returns the value as a list of integers.- Throws:
IllegalArgumentException
- if the value is not an array of ints.
-
getLongs
Returns the value as a list of longs.- Throws:
IllegalArgumentException
- if the value is not an array of longs.
-
getBytes
Returns the value as a list of bytes.- Throws:
IllegalArgumentException
- if the value is not an array of bytes.
-
getShorts
Returns the value as a list of shorts.- Throws:
IllegalArgumentException
- if the value is not an array of shorts.
-
getFloats
Returns the value as a list of floats.- Throws:
IllegalArgumentException
- if the value is not an array of floats.
-
getDoubles
Returns the value as a list of doubles.- Throws:
IllegalArgumentException
- if the value is not an array of doubles.
-
getBooleans
Returns the value as a list of booleans.- Throws:
IllegalArgumentException
- if the value is not an array of booleans.
-
getChars
Returns the value as a list of characters.- Throws:
IllegalArgumentException
- if the value is not an array of chars.
-
getAnnotationValues
public static com.google.common.collect.ImmutableList<AnnotationValue> getAnnotationValues(AnnotationValue value) Returns the value as a list ofAnnotationValue
s.- Throws:
IllegalArgumentException
- if the value is not an array.
-