Package io.micronaut.core.annotation
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
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 Summary
Modifier and TypeFieldDescriptionstatic final AnnotationClassValue<?>[]
An empty array of class values. -
Constructor Summary
ConstructorDescriptionAnnotationClassValue
(@NonNull String name, boolean instantiated) Constructs a class value for a type that is present.AnnotationClassValue
(Class<T> theClass) Constructs a class value for a type that is present.AnnotationClassValue
(String name) Constructs a class value for the type that is not present.AnnotationClassValue
(T instance) Constructs a class value for a type that is present. -
Method Summary
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Field Details
-
EMPTY_ARRAY
An empty array of class values.
-
-
Constructor Details
-
AnnotationClassValue
Constructs a class value for the type that is not present.- Parameters:
name
- The name of the type.
-
AnnotationClassValue
Constructs a class value for a type that is present.- Parameters:
theClass
- The type
-
AnnotationClassValue
Constructs a class value for a type that is present.- Parameters:
name
- the class nameinstantiated
- Whether at runtime an instance should be instantiated
-
AnnotationClassValue
Constructs a class value for a type that is present.- Parameters:
instance
- The instnace- Since:
- 1.1
-
-
Method Details
-
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 ongetInstance()
, except at compilation time when instances are not instantiated.- Returns:
- Whether this class value is instantiated
- Since:
- 1.1
-
getType
The type if present on the classpath.- Returns:
- The type
-
getName
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
equals
-
hashCode
public int hashCode()
-