Class AnnotationDescription.ForLoadedAnnotation<S extends java.lang.annotation.Annotation>
- java.lang.Object
-
- net.bytebuddy.description.annotation.AnnotationDescription.AbstractBase
-
- net.bytebuddy.description.annotation.AnnotationDescription.ForLoadedAnnotation<S>
-
- Type Parameters:
S
- The type of the annotation.
- All Implemented Interfaces:
AnnotationDescription
,AnnotationDescription.Loadable<S>
- Enclosing interface:
- AnnotationDescription
public static class AnnotationDescription.ForLoadedAnnotation<S extends java.lang.annotation.Annotation> extends AnnotationDescription.AbstractBase implements AnnotationDescription.Loadable<S>
A description of an already loaded annotation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.description.annotation.AnnotationDescription
AnnotationDescription.AbstractBase, AnnotationDescription.AnnotationInvocationHandler<T extends java.lang.annotation.Annotation>, AnnotationDescription.Builder, AnnotationDescription.ForLoadedAnnotation<S extends java.lang.annotation.Annotation>, AnnotationDescription.Latent, AnnotationDescription.Loadable<S extends java.lang.annotation.Annotation>, AnnotationDescription.RenderingDispatcher
-
-
Field Summary
Fields Modifier and Type Field Description private S
annotation
The represented annotation value.private java.lang.Class<S>
annotationType
The annotation's loaded type which might be loaded by a different class loader than the value's annotation type but must be structurally equal to it.-
Fields inherited from interface net.bytebuddy.description.annotation.AnnotationDescription
UNDEFINED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForLoadedAnnotation(S annotation)
Creates a new annotation description for a loaded annotation.private
ForLoadedAnnotation(S annotation, java.lang.Class<S> annotationType)
Creates a new annotation description for a loaded annotation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.Map<java.lang.String,AnnotationValue<?,?>>
asValue(java.lang.annotation.Annotation annotation)
Extracts the annotation values of an annotation into a property map.static AnnotationValue<?,?>
asValue(java.lang.Object value, java.lang.Class<?> type)
Transforms an annotation property to an annotation value.TypeDescription
getAnnotationType()
Returns a description of the annotation type of this annotation.AnnotationValue<?,?>
getValue(MethodDescription.InDefinedShape property)
Returns the value of this annotation.S
load()
Loads this annotation description.static <U extends java.lang.annotation.Annotation>
AnnotationDescription.Loadable<U>of(U annotation)
Creates a description of the given annotation.<T extends java.lang.annotation.Annotation>
AnnotationDescription.Loadable<T>prepare(java.lang.Class<T> annotationType)
Links this annotation description to a given annotation type such that it can be loaded.-
Methods inherited from class net.bytebuddy.description.annotation.AnnotationDescription.AbstractBase
equals, getElementTypes, getRetention, hashCode, isDocumented, isInherited, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.bytebuddy.description.annotation.AnnotationDescription
getElementTypes, getRetention, isDocumented, isInherited
-
-
-
-
Field Detail
-
annotation
private final S extends java.lang.annotation.Annotation annotation
The represented annotation value.
-
annotationType
private final java.lang.Class<S extends java.lang.annotation.Annotation> annotationType
The annotation's loaded type which might be loaded by a different class loader than the value's annotation type but must be structurally equal to it.
-
-
Constructor Detail
-
ForLoadedAnnotation
protected ForLoadedAnnotation(S annotation)
Creates a new annotation description for a loaded annotation.- Parameters:
annotation
- The annotation to represent.
-
ForLoadedAnnotation
private ForLoadedAnnotation(S annotation, java.lang.Class<S> annotationType)
Creates a new annotation description for a loaded annotation.- Parameters:
annotation
- The annotation to represent.annotationType
- The annotation's loaded type which might be loaded by a different class loader than the value's annotation type but must be structurally equal to it.
-
-
Method Detail
-
of
public static <U extends java.lang.annotation.Annotation> AnnotationDescription.Loadable<U> of(U annotation)
Creates a description of the given annotation.- Type Parameters:
U
- The type of the annotation.- Parameters:
annotation
- The annotation to be described.- Returns:
- A description of the given annotation.
-
load
public S load()
Loads this annotation description. This causes all classes referenced by the annotation value to be loaded. Without specifying a class loader, the annotation's class loader which was used to prepare this instance is used.- Specified by:
load
in interfaceAnnotationDescription.Loadable<S extends java.lang.annotation.Annotation>
- Returns:
- A loaded version of this annotation description.
-
asValue
private static java.util.Map<java.lang.String,AnnotationValue<?,?>> asValue(java.lang.annotation.Annotation annotation)
Extracts the annotation values of an annotation into a property map.- Parameters:
annotation
- The annotation to convert.- Returns:
- A mapping of property names to their annotation value.
-
asValue
public static AnnotationValue<?,?> asValue(java.lang.Object value, java.lang.Class<?> type)
Transforms an annotation property to an annotation value.- Parameters:
type
- The annotation's type.value
- The annotations value.- Returns:
- An annotation value representation.
-
getValue
public AnnotationValue<?,?> getValue(MethodDescription.InDefinedShape property)
Returns the value of this annotation.- Specified by:
getValue
in interfaceAnnotationDescription
- Parameters:
property
- The property being accessed.- Returns:
- The value for the supplied property.
-
prepare
public <T extends java.lang.annotation.Annotation> AnnotationDescription.Loadable<T> prepare(java.lang.Class<T> annotationType)
Links this annotation description to a given annotation type such that it can be loaded. This does not cause the values of this annotation to be loaded.- Specified by:
prepare
in interfaceAnnotationDescription
- Type Parameters:
T
- The type of the annotation.- Parameters:
annotationType
- The loaded annotation type of this annotation description.- Returns:
- A loadable version of this annotation description.
-
getAnnotationType
public TypeDescription getAnnotationType()
Returns a description of the annotation type of this annotation.- Specified by:
getAnnotationType
in interfaceAnnotationDescription
- Returns:
- A description of the annotation type of this annotation.
-
-