A
- The annotation typepublic class AnnotationValue<A extends Annotation> extends Object implements ValueResolver<CharSequence>
This class implements the ValueResolver
interface and methods such as ValueResolver.get(CharSequence, Class)
can be used to retrieve the values of annotation members.
If a member is not present then the methods of the class will attempt to resolve the default value for a given annotation member. In this sense the behaviour of this class is similar to how
a implementation of Annotation
behaves.
Modifier | Constructor and Description |
---|---|
protected |
AnnotationValue(AnnotationValue<A> target,
Map<String,Object> defaultValues,
ConvertibleValues<Object> convertibleValues)
Internal copy constructor.
|
|
AnnotationValue(String annotationName) |
|
AnnotationValue(String annotationName,
ConvertibleValues<Object> convertibleValues) |
|
AnnotationValue(String annotationName,
Map<CharSequence,Object> values) |
|
AnnotationValue(String annotationName,
Map<CharSequence,Object> values,
Map<String,Object> defaultValues) |
Modifier and Type | Method and Description |
---|---|
static <T extends Annotation> |
builder(Class<T> annotation)
Start building a new annotation for the given name.
|
static AnnotationValueBuilder<?> |
builder(String annotationName)
Start building a new annotation for the given name.
|
boolean |
contains(String member)
Whether a particular member is present.
|
boolean |
equals(Object obj) |
<T> Optional<T> |
get(CharSequence member,
ArgumentConversionContext<T> conversionContext)
Resolve the given property for the given name.
|
<T extends Annotation> |
getAnnotation(String member,
Class<T> type)
Gets a list of
AnnotationValue for the given member. |
String |
getAnnotationName()
The annotation name.
|
<T extends Annotation> |
getAnnotations(String member,
Class<T> type)
Gets a list of
AnnotationValue for the given member. |
ConvertibleValues<Object> |
getConvertibleValues() |
Set<CharSequence> |
getMemberNames()
Resolves the names of all the present annotation members.
|
<T> T |
getRequiredValue(Class<T> type)
Get the value of the
value member of the annotation. |
<T> T |
getRequiredValue(String member,
Class<T> type)
Get the value of the
value member of the annotation. |
<T> Optional<T> |
getValue(Argument<T> argument)
Get the value of the
value member of the annotation. |
<T> Optional<T> |
getValue(ArgumentConversionContext<T> conversionContext)
Get the value of the
value member of the annotation. |
<T> Optional<T> |
getValue(Class<T> type)
Get the value of the
value member of the annotation. |
Map<CharSequence,Object> |
getValues() |
int |
hashCode() |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
get, get, get
public AnnotationValue(String annotationName, Map<CharSequence,Object> values)
annotationName
- The annotation namevalues
- The valuespublic AnnotationValue(String annotationName, Map<CharSequence,Object> values, Map<String,Object> defaultValues)
annotationName
- The annotation namevalues
- The valuesdefaultValues
- The default valuespublic AnnotationValue(String annotationName)
annotationName
- The annotation namepublic AnnotationValue(String annotationName, ConvertibleValues<Object> convertibleValues)
annotationName
- The annotation nameconvertibleValues
- The convertible values@Internal protected AnnotationValue(AnnotationValue<A> target, Map<String,Object> defaultValues, ConvertibleValues<Object> convertibleValues)
target
- The targetdefaultValues
- The default valuesconvertibleValues
- The convertible values@Nonnull public final String getAnnotationName()
public final boolean contains(String member)
member
- The member@Nonnull public final Set<CharSequence> getMemberNames()
@Nonnull public Map<CharSequence,Object> getValues()
@Nonnull public ConvertibleValues<Object> getConvertibleValues()
public <T> Optional<T> get(CharSequence member, ArgumentConversionContext<T> conversionContext)
ValueResolver
get
in interface ValueResolver<CharSequence>
T
- The concrete typemember
- The nameconversionContext
- The conversion contextpublic <T> Optional<T> getValue(ArgumentConversionContext<T> conversionContext)
value
member of the annotation.T
- The typeconversionContext
- The conversion contextpublic final <T> Optional<T> getValue(Argument<T> argument)
value
member of the annotation.T
- The typeargument
- The argumentpublic final <T> Optional<T> getValue(Class<T> type)
value
member of the annotation.T
- The typetype
- The type@Nonnull public final <T> T getRequiredValue(Class<T> type)
value
member of the annotation.T
- The typetype
- The typeIllegalStateException
- If no member is available that conforms to the given type@Nonnull public final <T> T getRequiredValue(String member, Class<T> type)
value
member of the annotation.T
- The typemember
- The membertype
- The typeIllegalStateException
- If no member is available that conforms to the given name and type@Nonnull public final <T extends Annotation> List<AnnotationValue<T>> getAnnotations(String member, Class<T> type)
AnnotationValue
for the given member.T
- The typemember
- The membertype
- The typeIllegalStateException
- If no member is available that conforms to the given name and type@Nonnull public final <T extends Annotation> Optional<AnnotationValue<T>> getAnnotation(String member, Class<T> type)
AnnotationValue
for the given member.T
- The typemember
- The membertype
- The typeIllegalStateException
- If no member is available that conforms to the given name and typepublic static AnnotationValueBuilder<?> builder(String annotationName)
annotationName
- The annotation namepublic static <T extends Annotation> AnnotationValueBuilder<T> builder(Class<T> annotation)
T
- The annotation typeannotation
- The annotation name