Class AnnotationValues


  • public final class AnnotationValues
    extends java.lang.Object
    A utility class for working with AnnotationValue instances.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationValue> getAnnotationValues​(javax.lang.model.element.AnnotationValue annotationValue)
      Returns the list of values represented by an array annotation value.
      static boolean getBoolean​(javax.lang.model.element.AnnotationValue value)
      Returns the value as a boolean.
      static javax.lang.model.element.VariableElement getEnum​(javax.lang.model.element.AnnotationValue value)
      Returns the value as a VariableElement.
      static int[] getIntArrayValue​(javax.lang.model.element.AnnotationMirror annotation, java.lang.String valueName)
      Returns the int array value of an annotation
      static int getIntValue​(javax.lang.model.element.AnnotationMirror annotation, java.lang.String valueName)
      Returns the int value of an annotation
      static java.util.Optional<java.lang.Integer> getOptionalIntValue​(javax.lang.model.element.AnnotationMirror annotation, java.lang.String valueName)
      Returns an optional int value of an annotation if the value name is present
      static java.util.Optional<java.lang.String> getOptionalStringValue​(javax.lang.model.element.AnnotationMirror annotation, java.lang.String valueName)
      Returns an optional String value of an annotation if the value name is present
      static java.lang.String getString​(javax.lang.model.element.AnnotationValue value)
      Returns the value as a string.
      static java.lang.String[] getStringArrayValue​(javax.lang.model.element.AnnotationMirror annotation, java.lang.String valueName)
      Returns the String array value of an annotation
      static com.google.common.collect.ImmutableSet<java.lang.String> getStrings​(javax.lang.model.element.AnnotationValue value)
      Returns a string array value as a set of strings.
      static java.lang.String getStringValue​(javax.lang.model.element.AnnotationMirror annotation, java.lang.String valueName)
      Returns the String value of an annotation
      static javax.lang.model.element.TypeElement getTypeElement​(javax.lang.model.element.AnnotationValue value)
      Returns a class value as a TypeElement.
      static com.google.common.collect.ImmutableSet<javax.lang.model.element.TypeElement> getTypeElements​(javax.lang.model.element.AnnotationValue value)
      Returns a class array value as a set of TypeElement.
      static javax.lang.model.type.DeclaredType getTypeMirror​(javax.lang.model.element.AnnotationValue value)
      Returns the value as a class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getTypeMirror

        public static javax.lang.model.type.DeclaredType getTypeMirror​(javax.lang.model.element.AnnotationValue value)
        Returns the value as a class.
        Throws:
        java.lang.IllegalArgumentException - if the value is not a class.
      • getTypeElements

        public static com.google.common.collect.ImmutableSet<javax.lang.model.element.TypeElement> getTypeElements​(javax.lang.model.element.AnnotationValue value)
        Returns a class array value as a set of TypeElement.
      • getTypeElement

        public static javax.lang.model.element.TypeElement getTypeElement​(javax.lang.model.element.AnnotationValue value)
        Returns a class value as a TypeElement.
      • getEnum

        public static javax.lang.model.element.VariableElement getEnum​(javax.lang.model.element.AnnotationValue value)
        Returns the value as a VariableElement.
        Throws:
        java.lang.IllegalArgumentException - if the value is not an enum.
      • getStrings

        public static com.google.common.collect.ImmutableSet<java.lang.String> getStrings​(javax.lang.model.element.AnnotationValue value)
        Returns a string array value as a set of strings.
      • getString

        public static java.lang.String getString​(javax.lang.model.element.AnnotationValue value)
        Returns the value as a string.
        Throws:
        java.lang.IllegalArgumentException - if the value is not a string.
      • getBoolean

        public static boolean getBoolean​(javax.lang.model.element.AnnotationValue value)
        Returns the value as a boolean.
        Throws:
        java.lang.IllegalArgumentException - if the value is not a boolean.
      • getIntValue

        public static int getIntValue​(javax.lang.model.element.AnnotationMirror annotation,
                                      java.lang.String valueName)
        Returns the int value of an annotation
      • getOptionalIntValue

        public static java.util.Optional<java.lang.Integer> getOptionalIntValue​(javax.lang.model.element.AnnotationMirror annotation,
                                                                                java.lang.String valueName)
        Returns an optional int value of an annotation if the value name is present
      • getStringValue

        public static java.lang.String getStringValue​(javax.lang.model.element.AnnotationMirror annotation,
                                                      java.lang.String valueName)
        Returns the String value of an annotation
      • getOptionalStringValue

        public static java.util.Optional<java.lang.String> getOptionalStringValue​(javax.lang.model.element.AnnotationMirror annotation,
                                                                                  java.lang.String valueName)
        Returns an optional String value of an annotation if the value name is present
      • getIntArrayValue

        public static int[] getIntArrayValue​(javax.lang.model.element.AnnotationMirror annotation,
                                             java.lang.String valueName)
        Returns the int array value of an annotation
      • getStringArrayValue

        public static java.lang.String[] getStringArrayValue​(javax.lang.model.element.AnnotationMirror annotation,
                                                             java.lang.String valueName)
        Returns the String array value of an annotation
      • getAnnotationValues

        public static com.google.common.collect.ImmutableList<javax.lang.model.element.AnnotationValue> getAnnotationValues​(javax.lang.model.element.AnnotationValue annotationValue)
        Returns the list of values represented by an array annotation value.
        Throws:
        java.lang.IllegalArgumentException - unless annotationValue represents an array