Interface Annotation

All Superinterfaces:
Comparable<Annotation>, Prototype.Api
All Known Implementing Classes:
Annotation.BuilderBase.AnnotationImpl

public interface Annotation extends Prototype.Api, Comparable<Annotation>
An annotation with defined values.

Annotations can have the following values:

  • String - @TheAnnotation("some-value")
  • int - @TheAnnotation(49)
  • long - @TheAnnotation(49L)
  • boolean - @TheAnnotation(true)
  • byte - @TheAnnotation(49)
  • char - @TheAnnotation('x')
  • short - @TheAnnotation(1)
  • float - @TheAnnotation(4.2f)
  • double - @TheAnnotation(4.2)
  • enum value - @TheAnnotation(MyEnum.OPTION_1), default representation is String
  • Class - @TheAnnotation(MyType.class), default representation is String
  • another annotation - @TheAnnotation(@TheOtherAnnotation("some-value"))
  • arrays of the above - @TheAnnotation({"first-value", "second-value"}), represented as List
These types will be built into this type, with a few rules:
  • Any type except for another annotation and array is available as String (similar for arrays)
  • primitive types - only available as boxed types
  • Class - use string, the method that provides class instances uses Class.forName(String), which is not ideal, and may require additional configuration in native image
  • enum value - available as a String or enum value
  • another annotation - available as instance(s) of Annotation
  • arrays - available as a List of values
See Also:
  • Field Details

  • Method Details

    • builder

      static Annotation.Builder builder()
      Create a new fluent API builder to customize configuration.
      Returns:
      a new builder
    • builder

      static Annotation.Builder builder(Annotation instance)
      Create a new fluent API builder from an existing instance.
      Parameters:
      instance - an existing instance used as a base for the builder
      Returns:
      a builder based on an instance
    • create

      static Annotation create(Class<? extends Annotation> annoType)
      Creates an instance for an annotation with no value.
      Parameters:
      annoType - the annotation type
      Returns:
      the new instance
    • create

      static Annotation create(TypeName annoType)
      Creates an instance for an annotation with no value.
      Parameters:
      annoType - the annotation type
      Returns:
      the new instance
    • create

      static Annotation create(Class<? extends Annotation> annoType, String value)
      Creates an instance for an annotation with a value.
      Parameters:
      annoType - the annotation type
      value - the annotation value
      Returns:
      the new instance
    • create

      static Annotation create(Class<? extends Annotation> annoType, Map<String,?> values)
      Creates an instance for an annotation with a value.
      Parameters:
      annoType - the annotation type
      values - the annotation values
      Returns:
      the new instance
    • create

      static Annotation create(TypeName annoTypeName, String value)
      Creates an instance for an annotation with a value.
      Parameters:
      annoTypeName - the annotation type name
      value - the annotation value
      Returns:
      the new instance
    • create

      static Annotation create(TypeName annoTypeName, Map<String,?> values)
      Creates an instance for annotation with zero or more values.
      Parameters:
      annoTypeName - the annotation type name
      values - the annotation values
      Returns:
      the new instance
    • typeName

      TypeName typeName()
      The type name, e.g., Objects -> "java.util.Objects".
      Returns:
      the annotation type name
    • values

      Map<String,Object> values()
      Get a key-value of all the annotation properties.
      Returns:
      key-value pairs of all the properties present
    • value

      default Optional<String> value()
      The value property.
      Returns:
      the string value of value property
    • getValue

      default Optional<String> getValue(String property)
      Get a value of an annotation property.
      Parameters:
      property - name of the annotation property
      Returns:
      string value of the property
    • objectValue

      default Optional<Object> objectValue()
      Value of the annotation as an object. The type can be either String, or any primitive type, or Annotation, or list of these.
      Returns:
      object value
    • objectValue

      default Optional<Object> objectValue(String property)
      Value of the annotation property as an object. The type can be either String, or any primitive type, or Annotation, or list of these.
      Parameters:
      property - name of the annotation property
      Returns:
      object value
    • stringValue

      default Optional<String> stringValue()
      Typed value of the property "value".
      Returns:
      value if present
    • stringValue

      default Optional<String> stringValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • stringValues

      default Optional<List<String>> stringValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • stringValues

      default Optional<List<String>> stringValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • intValue

      default Optional<Integer> intValue()
      Typed value of the property "value".
      Returns:
      value if present
    • intValue

      default Optional<Integer> intValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • intValues

      default Optional<List<Integer>> intValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • intValues

      default Optional<List<Integer>> intValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • longValue

      default Optional<Long> longValue()
      Typed value of the property "value".
      Returns:
      value if present
    • longValue

      default Optional<Long> longValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • longValues

      default Optional<List<Long>> longValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • longValues

      default Optional<List<Long>> longValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • booleanValue

      default Optional<Boolean> booleanValue()
      Typed value of the property "value".
      Returns:
      value if present
    • booleanValue

      default Optional<Boolean> booleanValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • booleanValues

      default Optional<List<Boolean>> booleanValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • booleanValues

      default Optional<List<Boolean>> booleanValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • byteValue

      default Optional<Byte> byteValue()
      Typed value of the property "value".
      Returns:
      value if present
    • byteValue

      default Optional<Byte> byteValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • byteValues

      default Optional<List<Byte>> byteValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • byteValues

      default Optional<List<Byte>> byteValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • charValue

      default Optional<Character> charValue()
      Typed value of the property "value".
      Returns:
      value if present
    • charValue

      default Optional<Character> charValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • charValues

      default Optional<List<Character>> charValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • charValues

      default Optional<List<Character>> charValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • shortValue

      default Optional<Short> shortValue()
      Typed value of the property "value".
      Returns:
      value if present
    • shortValue

      default Optional<Short> shortValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • shortValues

      default Optional<List<Short>> shortValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • shortValues

      default Optional<List<Short>> shortValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • floatValue

      default Optional<Float> floatValue()
      Typed value of the property "value".
      Returns:
      value if present
    • floatValue

      default Optional<Float> floatValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • floatValues

      default Optional<List<Float>> floatValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • floatValues

      default Optional<List<Float>> floatValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • doubleValue

      default Optional<Double> doubleValue()
      Typed value of the property "value".
      Returns:
      value if present
    • doubleValue

      default Optional<Double> doubleValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • doubleValues

      default Optional<List<Double>> doubleValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • doubleValues

      default Optional<List<Double>> doubleValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • classValue

      default Optional<Class<?>> classValue()
      Typed value of the property "value".
      Returns:
      value if present
    • classValue

      default Optional<Class<?>> classValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • classValues

      default Optional<List<Class<?>>> classValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • classValues

      default Optional<List<Class<?>>> classValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • typeValue

      default Optional<TypeName> typeValue()
      Typed value of the property "value". Alternative for classValue().
      Returns:
      value if present
    • typeValue

      default Optional<TypeName> typeValue(String property)
      Typed value of a named property. Alternative for classValue(String).
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • typeValues

      default Optional<List<TypeName>> typeValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property. Alternative for classValues().
      Returns:
      list of defined values if present
    • typeValues

      default Optional<List<TypeName>> typeValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property. Alternative for classValues(String).
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • annotationValue

      default Optional<Annotation> annotationValue()
      Typed value of the property "value".
      Returns:
      value if present
    • annotationValue

      default Optional<Annotation> annotationValue(String property)
      Typed value of a named property.
      Parameters:
      property - name of the annotation property
      Returns:
      value if present
    • annotationValues

      default Optional<List<Annotation>> annotationValues()
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Returns:
      list of defined values if present
    • annotationValues

      default Optional<List<Annotation>> annotationValues(String property)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Parameters:
      property - name of the annotation property
      Returns:
      list of defined values if present
    • enumValue

      default <T extends Enum<T>> Optional<T> enumValue(Class<T> type)
      Typed value of the property "value".
      Type Parameters:
      T - type of the enumeration
      Parameters:
      type - class of the enumeration
      Returns:
      value if present
    • enumValue

      default <T extends Enum<T>> Optional<T> enumValue(String property, Class<T> type)
      Typed value of a named property.
      Type Parameters:
      T - type of the enumeration
      Parameters:
      property - name of the annotation property
      type - class of the enumeration
      Returns:
      value if present
    • enumValues

      default <T extends Enum<T>> Optional<List<T>> enumValues(Class<T> type)
      Typed value of the property "value" that is defined as an array. This will also work for a single values property.
      Type Parameters:
      T - type of the enumeration
      Parameters:
      type - class of the enumeration
      Returns:
      list of defined values if present
    • enumValues

      default <T extends Enum<T>> Optional<List<T>> enumValues(String property, Class<T> type)
      Typed values of a property that is defined as an array. This will also work for a single values property.
      Type Parameters:
      T - type of the enumeration
      Parameters:
      property - name of the annotation property
      type - class of the enumeration
      Returns:
      list of defined values if present