Class AnnotationClassValue<T>

java.lang.Object
io.micronaut.core.annotation.AnnotationClassValue<T>
Type Parameters:
T - The generic type of the underlying class
All Implemented Interfaces:
Named, CharSequence

public final class AnnotationClassValue<T> extends Object implements CharSequence, Named
An annotation class value is a reference to a class in annotation metadata. The class may or may not be present on the classpath. If it is present then the getType() method will return a non-empty optional.
Since:
1.0
Author:
graemerocher
  • Field Details

    • EMPTY_ARRAY

      public static final AnnotationClassValue<?>[] EMPTY_ARRAY
      An empty array of class values.
  • Constructor Details

    • AnnotationClassValue

      @Internal public AnnotationClassValue(String name)
      Constructs a class value for the type that is not present.
      Parameters:
      name - The name of the type.
    • AnnotationClassValue

      public AnnotationClassValue(Class<T> theClass)
      Constructs a class value for a type that is present.
      Parameters:
      theClass - The type
    • AnnotationClassValue

      @Internal public AnnotationClassValue(@NonNull @NonNull String name, boolean instantiated)
      Constructs a class value for a type that is present.
      Parameters:
      name - the class name
      instantiated - Whether at runtime an instance should be instantiated
    • AnnotationClassValue

      public AnnotationClassValue(@NonNull T instance)
      Constructs a class value for a type that is present.
      Parameters:
      instance - The instnace
      Since:
      1.1
  • Method Details

    • getInstance

      @NonNull public @NonNull Optional<T> getInstance()
      Returns the backing instance if there is one. Note this method will not attempt to instantiate the class via reflection and is designed for use via byte code generation.
      Returns:
      The instance
      Since:
      1.1
    • isInstantiated

      public boolean isInstantiated()
      Return whether the class value is instantiated. Normally this is the same as using isPresent on getInstance(), except at compilation time where instances are not instantiated.
      Returns:
      Whether this class value is instantiated
      Since:
      1.1
    • getType

      public Optional<Class<T>> getType()
      The type if present on the classpath.
      Returns:
      The type
    • getName

      public String getName()
      Specified by:
      getName in interface Named
      Returns:
      The name of the component
    • length

      public int length()
      Specified by:
      length in interface CharSequence
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • toString

      public String toString()
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object