类 TypeMappedAnnotation<A extends Annotation>
- 类型参数:
A- the annotation type
- 所有已实现的接口:
MergedAnnotation<A>
MergedAnnotation that adapts attributes from a root annotation by
applying the mapping and mirroring rules of an AnnotationTypeMapping.
Root attribute values are extracted from a source object using a supplied
BiFunction. This allows various different annotation models to be
supported by the same class. For example, the attributes source might be an
actual Annotation instance where methods on the annotation instance
are invoked to extract
values. Equally, the source could be a simple Map with values
extracted using Map.get(Object).
Extracted root attribute values must be compatible with the attribute return type, namely:
| Return Type | Extracted Type |
|---|---|
| Class | Class or String |
| Class[] | Class[] or String[] |
| Annotation | Annotation, Map, or Object compatible with the value extractor |
| Annotation[] | Annotation[], Map[], or Object[] where elements are compatible with the value extractor |
| Other types | An exact match or the appropriate primitive wrapper |
- 从以下版本开始:
- 4.0
- 作者:
- Phillip Webb, Juergen Hoeller, Sam Brannen
- 另请参阅:
-
嵌套类概要
从接口继承的嵌套类/接口 cn.taketoday.core.annotation.MergedAnnotation
MergedAnnotation.Adapt -
字段概要
字段修饰符和类型字段说明private final intprivate final ClassLoaderprivate final AnnotationTypeMappingprivate final int[]private final int[]private final Objectprivate final Objectprivate final booleanprivate final ValueExtractor从接口继承的字段 cn.taketoday.core.annotation.MergedAnnotation
VALUE -
构造器概要
构造器限定符构造器说明privateTypeMappedAnnotation(AnnotationTypeMapping mapping, ClassLoader classLoader, Object source, Object rootAttributes, ValueExtractor valueExtractor, int aggregateIndex) privateTypeMappedAnnotation(AnnotationTypeMapping mapping, ClassLoader classLoader, Object source, Object rootAnnotation, ValueExtractor valueExtractor, int aggregateIndex, boolean useMergedValues, Predicate<String> attributeFilter, int[] resolvedRootMirrors, int[] resolvedMirrors) privateTypeMappedAnnotation(AnnotationTypeMapping mapping, ClassLoader classLoader, Object source, Object rootAttributes, ValueExtractor valueExtractor, int aggregateIndex, int[] resolvedRootMirrors) -
方法概要
修饰符和类型方法说明private <T> Tprivate ObjectadaptForAttribute(Method attribute, Object value) private MergedAnnotation<?>adaptToMergedAnnotation(Object value, Class<? extends Annotation> annotationType) adaptValueForMapOptions(Method attribute, Object value, Class<?> mapType, Function<MergedAnnotation<?>, T> factory, MergedAnnotation.Adapt[] adaptations) asMap(MergedAnnotation.Adapt... adaptations) Get an immutableMapthat contains all the annotation attributes.asMap(Function<MergedAnnotation<?>, T> factory, MergedAnnotation.Adapt... adaptations) Create a newMapinstance of the given type that contains all the annotation attributes.(专用程序包) static <A extends Annotation>
TypeMappedAnnotation<A>createIfPossible(AnnotationTypeMapping mapping, MergedAnnotation<?> annotation, IntrospectionFailureLogger logger) (专用程序包) static <A extends Annotation>
TypeMappedAnnotation<A>createIfPossible(AnnotationTypeMapping mapping, Object source, Annotation annotation, int aggregateIndex, IntrospectionFailureLogger logger) private static <A extends Annotation>
TypeMappedAnnotation<A>createIfPossible(AnnotationTypeMapping mapping, Object source, Object rootAttribute, ValueExtractor valueExtractor, int aggregateIndex, IntrospectionFailureLogger logger) protected AFactory method used to create the synthesized annotation.private ObjectemptyArray(Class<?> componentType) (专用程序包) static ObjectextractFromMap(Method attribute, Object map) filterAttributes(Predicate<String> predicate) Create a new view of the annotation with only attributes that match the given predicate.(专用程序包) static <A extends Annotation>
TypeMappedAnnotation<A>Create a newMergedAnnotationinstance from the specified annotation.private <T> Class<T>getAdaptType(Method attribute, Class<T> type) intGet the index of the aggregate collection containing this annotation.<T extends Annotation>
MergedAnnotation<T>getAnnotation(String attributeName, Class<T> type) Get a required annotation attribute value from the annotation.<T extends Annotation>
MergedAnnotation<T>[]getAnnotationArray(String attributeName, Class<T> type) Get a required annotation array attribute value from the annotation.private intgetAttributeIndex(String attributeName, boolean required) protected <T> TgetAttributeValue(String attributeName, Class<T> type) Get the underlying attribute value.private ClassLoader<T> Optional<T>getDefaultValue(String attributeName, Class<T> type) Get the default attribute value from the annotation as specified in the annotation declaration.intGet the distance of this annotation related to its use as a meta-annotation.Get the source of the meta-annotation, ornullif the annotation is not meta-present.List<Class<? extends Annotation>>Get the complete list of annotation types within the annotation hierarchy from this annotation to theroot.private ObjectgetRequiredValue(int attributeIndex, String attributeName) getRoot()Get the root annotation, i.e. thedistance0annotation as directly declared on the source.Get the source that ultimately declared the root annotation, ornullif the source is not known.getType()Get theClassreference for the actual annotation type.private Class<?>getTypeForMapOptions(Method attribute, MergedAnnotation.Adapt[] adaptations) private ObjectgetValue(int attributeIndex, boolean useConventionMapping, boolean forMirrorResolution) private <T> Tprivate ValueExtractorgetValueExtractor(Object value) private ObjectgetValueForMirrorResolution(Method attribute, Object annotation) private ObjectgetValueFromMetaAnnotation(int attributeIndex, boolean forMirrorResolution) booleanhasDefaultValue(String attributeName) Determine if the specified attribute name has a default value when compared to the annotation declaration.private booleanisEmptyObjectArray(Object value) private booleanisFiltered(String attributeName) private booleanisNotSynthesizable(Annotation annotation) Determine if the supplied annotation has not already been synthesized and whether the mapped annotation is a composed annotation that needs to have its attributes merged or the mapped annotation is synthesizable in general.booleanDetermine if the annotation is present on the source.booleanDetermine if this merged annotation is synthesizable.(专用程序包) static <A extends Annotation>
MergedAnnotation<A>Create a new view of the annotation that exposes non-merged attribute values.从类继承的方法 cn.taketoday.core.annotation.AbstractMergedAnnotation
asAnnotationAttributes, filterDefaultValues, getBoolean, getBooleanArray, getByte, getByteArray, getChar, getCharArray, getClass, getClassArray, getDefaultValue, getDouble, getDoubleArray, getEnum, getEnumArray, getFloat, getFloatArray, getInt, getIntArray, getLong, getLongArray, getShort, getShortArray, getString, getStringArray, getValue, getValue, hasNonDefaultValue, isDirectlyPresent, isMetaPresent, synthesize, synthesize从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.core.annotation.MergedAnnotation
getBooleanValue, getClassValue, getClassValueArray, getDoubleValue, getIntValue, getLongValue, getStringValue, getStringValueArray, getValue
-
字段详细资料
-
EMPTY_ARRAYS
-
mapping
-
classLoader
-
source
-
rootAttributes
-
valueExtractor
-
aggregateIndex
private final int aggregateIndex -
useMergedValues
private final boolean useMergedValues -
attributeFilter
-
resolvedRootMirrors
private final int[] resolvedRootMirrors -
resolvedMirrors
private final int[] resolvedMirrors
-
-
构造器详细资料
-
TypeMappedAnnotation
private TypeMappedAnnotation(AnnotationTypeMapping mapping, @Nullable ClassLoader classLoader, @Nullable Object source, @Nullable Object rootAttributes, ValueExtractor valueExtractor, int aggregateIndex) -
TypeMappedAnnotation
private TypeMappedAnnotation(AnnotationTypeMapping mapping, @Nullable ClassLoader classLoader, @Nullable Object source, @Nullable Object rootAttributes, ValueExtractor valueExtractor, int aggregateIndex, @Nullable int[] resolvedRootMirrors) -
TypeMappedAnnotation
private TypeMappedAnnotation(AnnotationTypeMapping mapping, @Nullable ClassLoader classLoader, @Nullable Object source, @Nullable Object rootAnnotation, ValueExtractor valueExtractor, int aggregateIndex, boolean useMergedValues, @Nullable Predicate<String> attributeFilter, int[] resolvedRootMirrors, int[] resolvedMirrors)
-
-
方法详细资料
-
getType
从接口复制的说明:MergedAnnotationGet theClassreference for the actual annotation type.- 返回:
- the annotation type
-
getMetaTypes
从接口复制的说明:MergedAnnotationGet the complete list of annotation types within the annotation hierarchy from this annotation to theroot.Provides a useful way to uniquely identify a merged annotation instance.
- 返回:
- the meta types for the annotation
- 另请参阅:
-
isPresent
public boolean isPresent()从接口复制的说明:MergedAnnotationDetermine if the annotation is present on the source. Considers directly present and meta-present annotations within the context of theMergedAnnotations.SearchStrategyused.- 返回:
trueif the annotation is present
-
getDistance
public int getDistance()从接口复制的说明:MergedAnnotationGet the distance of this annotation related to its use as a meta-annotation.A directly declared annotation has a distance of
0, a meta-annotation has a distance of1, a meta-annotation on a meta-annotation has a distance of2, etc. A missing annotation will always return a distance of-1.- 返回:
- the annotation distance or
-1if the annotation is missing
-
getAggregateIndex
public int getAggregateIndex()从接口复制的说明:MergedAnnotationGet the index of the aggregate collection containing this annotation.Can be used to reorder a stream of annotations, for example, to give a higher priority to annotations declared on a superclass or interface. A missing annotation will always return an aggregate index of
-1.- 返回:
- the aggregate index (starting at
0) or-1if the annotation is missing
-
getSource
从接口复制的说明:MergedAnnotationGet the source that ultimately declared the root annotation, ornullif the source is not known.If this merged annotation was created
fromanAnnotatedElementthen this source will be an element of the same type. If the annotation was loaded without using reflection, the source can be of any type, but should have a sensibletoString(). Meta-annotations will always return the same source as theroot.- 返回:
- the source, or
null
-
getMetaSource
从接口复制的说明:MergedAnnotationGet the source of the meta-annotation, ornullif the annotation is not meta-present.The meta-source is the annotation that was meta-annotated with this annotation.
- 返回:
- the meta-annotation source or
null - 另请参阅:
-
getRoot
从接口复制的说明:MergedAnnotationGet the root annotation, i.e. thedistance0annotation as directly declared on the source.- 返回:
- the root annotation
- 另请参阅:
-
hasDefaultValue
从接口复制的说明:MergedAnnotationDetermine if the specified attribute name has a default value when compared to the annotation declaration.- 参数:
attributeName- the attribute name- 返回:
trueif the attribute value is the same as the default value
-
getAnnotation
public <T extends Annotation> MergedAnnotation<T> getAnnotation(String attributeName, Class<T> type) throws NoSuchElementException 从接口复制的说明:MergedAnnotationGet a required annotation attribute value from the annotation.- 参数:
attributeName- the attribute nametype- the annotation type- 返回:
- the value as a
MergedAnnotation - 抛出:
NoSuchElementException- if there is no matching attribute
-
getAnnotationArray
public <T extends Annotation> MergedAnnotation<T>[] getAnnotationArray(String attributeName, Class<T> type) throws NoSuchElementException 从接口复制的说明:MergedAnnotationGet a required annotation array attribute value from the annotation.- 参数:
attributeName- the attribute nametype- the annotation type- 返回:
- the value as a
MergedAnnotationarray - 抛出:
NoSuchElementException- if there is no matching attribute
-
getDefaultValue
从接口复制的说明:MergedAnnotationGet the default attribute value from the annotation as specified in the annotation declaration.- 参数:
attributeName- the attribute nametype- the attribute type. Must be compatible with the underlying attribute type orObject.class.- 返回:
- an optional of the default value or
Optional.empty()if there is no matching attribute or no defined default
-
filterAttributes
从接口复制的说明:MergedAnnotationCreate a new view of the annotation with only attributes that match the given predicate.- 参数:
predicate- a predicate used to filter attribute names- 返回:
- a filtered view of the annotation
- 另请参阅:
-
withNonMergedAttributes
从接口复制的说明:MergedAnnotationCreate a new view of the annotation that exposes non-merged attribute values.Methods from this view will return attribute values with only alias mirroring rules applied. Aliases to
meta-sourceattributes will not be applied.- 返回:
- a non-merged view of the annotation
-
asMap
从接口复制的说明:MergedAnnotationGet an immutableMapthat contains all the annotation attributes.The
adaptationsmay be used to change the way that values are added.- 参数:
adaptations- the adaptations that should be applied to the annotation values- 返回:
- an immutable map containing the attributes and values
-
asMap
public <T extends Map<String,Object>> T asMap(Function<MergedAnnotation<?>, T> factory, MergedAnnotation.Adapt... adaptations) 从接口复制的说明:MergedAnnotationCreate a newMapinstance of the given type that contains all the annotation attributes.The
adaptationsmay be used to change the way that values are added.- 参数:
factory- a map factoryadaptations- the adaptations that should be applied to the annotation values- 返回:
- a map containing the attributes and values
-
getTypeForMapOptions
-
adaptValueForMapOptions
private <T extends Map<String,Object>> Object adaptValueForMapOptions(Method attribute, Object value, Class<?> mapType, Function<MergedAnnotation<?>, T> factory, MergedAnnotation.Adapt[] adaptations) -
isSynthesizable
public boolean isSynthesizable()从接口复制的说明:MergedAnnotationDetermine if this merged annotation is synthesizable.Consult the documentation for
MergedAnnotation.synthesize()for an explanation of what is considered synthesizable.- 返回:
trueif the mapped annotation is synthesizable
-
createSynthesizedAnnotation
从类复制的说明:AbstractMergedAnnotationFactory method used to create the synthesized annotation.If the source is an annotation that is not synthesizable, it will be returned unmodified.
Consult the documentation for
MergedAnnotation.synthesize()for an explanation of what is considered synthesizable.- 指定者:
createSynthesizedAnnotation在类中AbstractMergedAnnotation<A extends Annotation>
-
isNotSynthesizable
Determine if the supplied annotation has not already been synthesized and whether the mapped annotation is a composed annotation that needs to have its attributes merged or the mapped annotation is synthesizable in general.- 参数:
annotation- the annotation to check
-
getAttributeValue
从类复制的说明:AbstractMergedAnnotationGet the underlying attribute value.- 指定者:
getAttributeValue在类中AbstractMergedAnnotation<A extends Annotation>- 参数:
attributeName- the attribute nametype- the type to return (seeMergedAnnotationclass documentation for details)- 返回:
- the attribute value or
nullif the value is not found and is not required
-
getRequiredValue
-
getValue
-
getValue
-
getValueFromMetaAnnotation
-
getValueForMirrorResolution
-
adapt
-
adaptForAttribute
-
isEmptyObjectArray
-
emptyArray
-
adaptToMergedAnnotation
private MergedAnnotation<?> adaptToMergedAnnotation(Object value, Class<? extends Annotation> annotationType) -
getValueExtractor
-
getAdaptType
-
getAttributeIndex
-
isFiltered
-
getClassLoader
-
from
从接口复制的说明:MergedAnnotationCreate a newMergedAnnotationinstance from the specified annotation.- 参数:
source- the source for the annotation. This source is used only for information and logging. It does not need to actually contain the specified annotations, and it will not be searched.annotation- the annotation to include- 返回:
- a
MergedAnnotationinstance for the annotation
-
of
static <A extends Annotation> MergedAnnotation<A> of(@Nullable ClassLoader classLoader, @Nullable Object source, Class<A> annotationType, @Nullable Map<String, ?> attributes) -
createIfPossible
@Nullable static <A extends Annotation> TypeMappedAnnotation<A> createIfPossible(AnnotationTypeMapping mapping, MergedAnnotation<?> annotation, IntrospectionFailureLogger logger) -
createIfPossible
@Nullable static <A extends Annotation> TypeMappedAnnotation<A> createIfPossible(AnnotationTypeMapping mapping, @Nullable Object source, Annotation annotation, int aggregateIndex, IntrospectionFailureLogger logger) -
createIfPossible
@Nullable private static <A extends Annotation> TypeMappedAnnotation<A> createIfPossible(AnnotationTypeMapping mapping, @Nullable Object source, @Nullable Object rootAttribute, ValueExtractor valueExtractor, int aggregateIndex, IntrospectionFailureLogger logger) -
extractFromMap
-