Package com.google.auto.common
Class AnnotationValues
- java.lang.Object
-
- com.google.auto.common.AnnotationValues
-
public final class AnnotationValues extends Object
A utility class for working withAnnotationValue
instances.- Author:
- Christian Gruber
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.google.common.base.Equivalence<AnnotationValue>
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.static AnnotationMirror
getAnnotationMirror(AnnotationValue value)
Returns the value as an AnnotationMirror.static com.google.common.collect.ImmutableList<AnnotationMirror>
getAnnotationMirrors(AnnotationValue value)
Returns the value as a list of annotations.static com.google.common.collect.ImmutableList<AnnotationValue>
getAnnotationValues(AnnotationValue value)
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.
-
-
-
Method Detail
-
equivalence
public static com.google.common.base.Equivalence<AnnotationValue> 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:
AnnotationMirrors.equivalence()
-
getTypeMirror
public static DeclaredType getTypeMirror(AnnotationValue value)
Returns the value as a class.- Throws:
IllegalArgumentException
- if the value is not a class.
-
getAnnotationMirror
public static AnnotationMirror getAnnotationMirror(AnnotationValue value)
Returns the value as an AnnotationMirror.- Throws:
IllegalArgumentException
- if the value is not an annotation.
-
getEnum
public static VariableElement getEnum(AnnotationValue value)
Returns the value as a VariableElement.- Throws:
IllegalArgumentException
- if the value is not an enum.
-
getString
public static String getString(AnnotationValue value)
Returns the value as a string.- Throws:
IllegalArgumentException
- if the value is not a string.
-
getInt
public static int getInt(AnnotationValue value)
Returns the value as an int.- Throws:
IllegalArgumentException
- if the value is not an int.
-
getLong
public static long getLong(AnnotationValue value)
Returns the value as a long.- Throws:
IllegalArgumentException
- if the value is not a long.
-
getByte
public static byte getByte(AnnotationValue value)
Returns the value as a byte.- Throws:
IllegalArgumentException
- if the value is not a byte.
-
getShort
public static short getShort(AnnotationValue value)
Returns the value as a short.- Throws:
IllegalArgumentException
- if the value is not a short.
-
getFloat
public static float getFloat(AnnotationValue value)
Returns the value as a float.- Throws:
IllegalArgumentException
- if the value is not a float.
-
getDouble
public static double getDouble(AnnotationValue value)
Returns the value as a double.- Throws:
IllegalArgumentException
- if the value is not a double.
-
getBoolean
public static boolean getBoolean(AnnotationValue value)
Returns the value as a boolean.- Throws:
IllegalArgumentException
- if the value is not a boolean.
-
getChar
public static char getChar(AnnotationValue value)
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
public static com.google.common.collect.ImmutableList<String> getStrings(AnnotationValue value)
Returns the value as a list of strings.- Throws:
IllegalArgumentException
- if the value is not an array of strings.
-
getInts
public static com.google.common.collect.ImmutableList<Integer> getInts(AnnotationValue value)
Returns the value as a list of integers.- Throws:
IllegalArgumentException
- if the value is not an array of ints.
-
getLongs
public static com.google.common.collect.ImmutableList<Long> getLongs(AnnotationValue value)
Returns the value as a list of longs.- Throws:
IllegalArgumentException
- if the value is not an array of longs.
-
getBytes
public static com.google.common.collect.ImmutableList<Byte> getBytes(AnnotationValue value)
Returns the value as a list of bytes.- Throws:
IllegalArgumentException
- if the value is not an array of bytes.
-
getShorts
public static com.google.common.collect.ImmutableList<Short> getShorts(AnnotationValue value)
Returns the value as a list of shorts.- Throws:
IllegalArgumentException
- if the value is not an array of shorts.
-
getFloats
public static com.google.common.collect.ImmutableList<Float> getFloats(AnnotationValue value)
Returns the value as a list of floats.- Throws:
IllegalArgumentException
- if the value is not an array of floats.
-
getDoubles
public static com.google.common.collect.ImmutableList<Double> getDoubles(AnnotationValue value)
Returns the value as a list of doubles.- Throws:
IllegalArgumentException
- if the value is not an array of doubles.
-
getBooleans
public static com.google.common.collect.ImmutableList<Boolean> getBooleans(AnnotationValue value)
Returns the value as a list of booleans.- Throws:
IllegalArgumentException
- if the value is not an array of booleans.
-
getChars
public static com.google.common.collect.ImmutableList<Character> getChars(AnnotationValue value)
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.
-
-