Class AnnotationClassValue<T>

  • Type Parameters:
    T - The generic type of the underlying class
    All Implemented Interfaces:
    Named, java.lang.CharSequence

    public final class AnnotationClassValue<T>
    extends java.lang.Object
    implements java.lang.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
    • Constructor Summary

      Constructors 
      Constructor Description
      AnnotationClassValue​(java.lang.Class<T> theClass)
      Constructs a class value for a type that is present.
      AnnotationClassValue​(java.lang.String name)
      Constructs a class value for the type that is not present.
      AnnotationClassValue​(java.lang.String name, boolean instantiated)
      Constructs a class value for a type that is present.
      AnnotationClassValue​(T instance)
      Constructs a class value for a type that is present.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      char charAt​(int index)  
      boolean equals​(java.lang.Object o)  
      java.util.Optional<T> getInstance()
      Returns the backing instance if there is one.
      java.lang.String getName()  
      java.util.Optional<java.lang.Class<T>> getType()
      The type if present on the classpath.
      int hashCode()  
      boolean isInstantiated()
      Return whether the class value is instantiated.
      int length()  
      java.lang.CharSequence subSequence​(int start, int end)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.CharSequence

        chars, codePoints
    • Field Detail

      • EMPTY_ARRAY

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

      • AnnotationClassValue

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

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

        @Internal
        public AnnotationClassValue​(@NonNull
                                    java.lang.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 Detail

      • getInstance

        @NonNull
        public java.util.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 java.util.Optional<java.lang.Class<T>> getType()
        The type if present on the classpath.
        Returns:
        The type
      • getName

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

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

        public char charAt​(int index)
        Specified by:
        charAt in interface java.lang.CharSequence
      • subSequence

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

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object