public abstract class AnnotationUtils extends Object
Annotation UtilitiesAnnotation| 限定符和类型 | 字段和说明 |
|---|---|
static String |
ANNOTATED_ELEMENT_UTILS_CLASS_NAME
The class name of AnnotatedElementUtils that is introduced since Spring Framework 4
|
| 构造器和说明 |
|---|
AnnotationUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <A extends Annotation> |
findAnnotations(Method method,
Class<A> annotationClass)
Find specified
Annotation type maps from Method |
static org.springframework.core.annotation.AnnotationAttributes |
getAnnotationAttributes(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationType,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap,
boolean ignoreDefaultValue,
boolean tryMergedAnnotation,
String... ignoreAttributeNames)
Get the
AnnotationAttributes, if the argument tryMergedAnnotation is true,
the AnnotationAttributes will be got from
merged annotation first,
if failed, and then to get from
normal one |
static org.springframework.core.annotation.AnnotationAttributes |
getAnnotationAttributes(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationType,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap,
boolean ignoreDefaultValue,
String... ignoreAttributeNames)
Get the
AnnotationAttributes |
static org.springframework.core.annotation.AnnotationAttributes |
getAnnotationAttributes(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationType,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean ignoreDefaultValue,
boolean tryMergedAnnotation,
String... ignoreAttributeNames)
Get the
AnnotationAttributes, if the argument tryMergedAnnotation is true,
the AnnotationAttributes will be got from
merged annotation first,
if failed, and then to get from
normal one |
static org.springframework.core.annotation.AnnotationAttributes |
getAnnotationAttributes(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationType,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean ignoreDefaultValue,
String... ignoreAttributeNames)
Get the
AnnotationAttributes |
static org.springframework.core.annotation.AnnotationAttributes |
getAnnotationAttributes(Annotation annotation,
boolean ignoreDefaultValue,
String... ignoreAttributeNames)
Get the
AnnotationAttributes |
static org.springframework.core.annotation.AnnotationAttributes |
getAnnotationAttributes(Annotation annotation,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap,
boolean ignoreDefaultValue,
String... ignoreAttributeNames)
Get the
AnnotationAttributes |
static org.springframework.core.annotation.AnnotationAttributes |
getAnnotationAttributes(Annotation annotation,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean ignoreDefaultValue,
String... ignoreAttributeNames)
Get the
AnnotationAttributes |
static <T> T |
getAttribute(Annotation annotation,
String attributeName)
Get the attribute value
|
static <T> T |
getAttribute(Map<String,Object> attributes,
String attributeName)
Get the attribute value
|
static <T> T |
getAttribute(Map<String,Object> attributes,
String attributeName,
boolean required)
Get the attribute value the will
|
static <T> T |
getAttribute(Map<String,Object> attributes,
String attributeName,
T defaultValue)
Get the attribute value with default value
|
static Map<String,Object> |
getAttributes(Annotation annotation,
boolean ignoreDefaultValue,
String... ignoreAttributeNames)
Get the
Annotation attributes |
static Map<String,Object> |
getAttributes(Annotation annotation,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap,
boolean ignoreDefaultValue,
String... ignoreAttributeNames) |
static Map<String,Object> |
getAttributes(Annotation annotation,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean ignoreDefaultValue,
String... ignoreAttributeNames)
Get the
Annotation attributes |
static Map<String,Object> |
getAttributes(Map<String,Object> annotationAttributes,
org.springframework.core.env.PropertyResolver propertyResolver,
String... ignoreAttributeNames)
Get the
Annotation attributes |
static <T> T |
getRequiredAttribute(Map<String,Object> attributes,
String attributeName)
Get the required attribute value
|
static <A extends Annotation> |
isPresent(Method method,
Class<A> annotationClass)
Is specified
Annotation present on Method's declaring class or parameters or itself. |
static Annotation |
tryGetMergedAnnotation(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationType)
Try to get the merged
annotation |
static Annotation |
tryGetMergedAnnotation(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationType,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap)
Try to get the merged
annotation |
static org.springframework.core.annotation.AnnotationAttributes |
tryGetMergedAnnotationAttributes(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationType,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap,
boolean ignoreDefaultValue,
String... ignoreAttributeNames)
Try to get
the annotation attributes after merging and resolving the placeholders |
static org.springframework.core.annotation.AnnotationAttributes |
tryGetMergedAnnotationAttributes(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationType,
org.springframework.core.env.PropertyResolver propertyResolver,
boolean ignoreDefaultValue,
String... ignoreAttributeNames)
Try to get
the annotation attributes after merging and resolving the placeholders |
public static <A extends Annotation> boolean isPresent(Method method, Class<A> annotationClass)
Annotation present on Method's declaring class or parameters or itself.A - Annotation typemethod - MethodannotationClass - Annotation typetrue , or falsepublic static <A extends Annotation> Map<ElementType,List<A>> findAnnotations(Method method, Class<A> annotationClass)
Annotation type maps from MethodA - Annotation typemethod - MethodannotationClass - Annotation typeAnnotation type maps , the ElementType as key ,
the list of Annotation as value.
If Annotation was annotated on Method's parametersElementType.PARAMETER ,
the associated Annotation list may contain multiple elements.public static Map<String,Object> getAttributes(Annotation annotation, boolean ignoreDefaultValue, String... ignoreAttributeNames)
Annotation attributesannotation - specified AnnotationignoreDefaultValue - whether ignore default value or notignoreAttributeNames - the attribute names of annotation should be ignoredpublic static Map<String,Object> getAttributes(Annotation annotation, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, String... ignoreAttributeNames)
Annotation attributesannotation - specified AnnotationpropertyResolver - PropertyResolver instance, e.g EnvironmentignoreDefaultValue - whether ignore default value or notignoreAttributeNames - the attribute names of annotation should be ignoredpublic static Map<String,Object> getAttributes(Map<String,Object> annotationAttributes, org.springframework.core.env.PropertyResolver propertyResolver, String... ignoreAttributeNames)
Annotation attributesannotationAttributes - the attributes of specified AnnotationpropertyResolver - PropertyResolver instance, e.g EnvironmentignoreAttributeNames - the attribute names of annotation should be ignoredpublic static Map<String,Object> getAttributes(Annotation annotation, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, String... ignoreAttributeNames)
annotation - specified AnnotationpropertyResolver - PropertyResolver instance, e.g EnvironmentclassValuesAsString - whether to turn Class references into Strings (for
compatibility with AnnotationMetadata or to
preserve them as Class referencesnestedAnnotationsAsMap - whether to turn nested Annotation instances into
AnnotationAttributes maps (for compatibility with
AnnotationMetadata or to preserve them as
Annotation instancesignoreDefaultValue - whether ignore default value or notignoreAttributeNames - the attribute names of annotation should be ignoredpublic static <T> T getAttribute(Annotation annotation, String attributeName)
T - the type of attribute valueannotation - annotationattributeName - the name of attributepublic static <T> T getAttribute(Map<String,Object> attributes, String attributeName)
T - the type of attribute valueattributes - the annotation attributes or AnnotationAttributesattributeName - the name of attributepublic static <T> T getAttribute(Map<String,Object> attributes, String attributeName, boolean required)
T - the type of attribute valueattributes - the annotation attributes or AnnotationAttributesattributeName - the name of attributerequired - the required attribute or notIllegalStateException - if attribute value can't be foundpublic static <T> T getAttribute(Map<String,Object> attributes, String attributeName, T defaultValue)
T - the type of attribute valueattributes - the annotation attributes or AnnotationAttributesattributeName - the name of attributedefaultValue - the default value of attributepublic static <T> T getRequiredAttribute(Map<String,Object> attributes, String attributeName)
T - the type of attribute valueattributes - the annotation attributes or AnnotationAttributesattributeName - the name of attributeIllegalStateException - if attribute value can't be foundpublic static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes(Annotation annotation, boolean ignoreDefaultValue, String... ignoreAttributeNames)
AnnotationAttributesannotation - specified AnnotationignoreDefaultValue - whether ignore default value or notignoreAttributeNames - the attribute names of annotation should be ignoredgetAnnotationAttributes(Annotation, PropertyResolver, boolean, String...)public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes(Annotation annotation, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, String... ignoreAttributeNames)
AnnotationAttributesannotation - specified AnnotationpropertyResolver - PropertyResolver instance, e.g EnvironmentclassValuesAsString - whether to turn Class references into Strings (for
compatibility with AnnotationMetadata or to
preserve them as Class referencesnestedAnnotationsAsMap - whether to turn nested Annotation instances into
AnnotationAttributes maps (for compatibility with
AnnotationMetadata or to preserve them as
Annotation instancesignoreAttributeNames - the attribute names of annotation should be ignoredignoreDefaultValue - whether ignore default value or notgetAttributes(Annotation, PropertyResolver, boolean, String...),
getAnnotationAttributes(AnnotatedElement, Class, PropertyResolver, boolean, String...)public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes(Annotation annotation, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, String... ignoreAttributeNames)
AnnotationAttributesannotation - specified AnnotationpropertyResolver - PropertyResolver instance, e.g EnvironmentignoreDefaultValue - whether ignore default value or notignoreAttributeNames - the attribute names of annotation should be ignoredgetAttributes(Annotation, PropertyResolver, boolean, String...),
getAnnotationAttributes(AnnotatedElement, Class, PropertyResolver, boolean, String...)public static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, String... ignoreAttributeNames)
AnnotationAttributesannotatedElement - the annotated elementannotationType - the tyoe pf annotationpropertyResolver - PropertyResolver instance, e.g EnvironmentignoreDefaultValue - whether ignore default value or notignoreAttributeNames - the attribute names of annotation should be ignoredannotatedElement can't be found in annotatedElement, return nullpublic static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, String... ignoreAttributeNames)
AnnotationAttributesannotatedElement - the annotated elementannotationType - the tyoe pf annotationpropertyResolver - PropertyResolver instance, e.g EnvironmentignoreDefaultValue - whether ignore default value or notignoreAttributeNames - the attribute names of annotation should be ignoredannotatedElement can't be found in annotatedElement, return nullpublic static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, boolean tryMergedAnnotation, String... ignoreAttributeNames)
AnnotationAttributes, if the argument tryMergedAnnotation is true,
the AnnotationAttributes will be got from
merged annotation first,
if failed, and then to get from
normal oneannotatedElement - the annotated elementannotationType - the tyoe pf annotationpropertyResolver - PropertyResolver instance, e.g EnvironmentignoreDefaultValue - whether ignore default value or nottryMergedAnnotation - whether try merged annotation or notignoreAttributeNames - the attribute names of annotation should be ignoredannotatedElement can't be found in annotatedElement, return nullpublic static org.springframework.core.annotation.AnnotationAttributes getAnnotationAttributes(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, boolean tryMergedAnnotation, String... ignoreAttributeNames)
AnnotationAttributes, if the argument tryMergedAnnotation is true,
the AnnotationAttributes will be got from
merged annotation first,
if failed, and then to get from
normal oneannotatedElement - the annotated elementannotationType - the tyoe pf annotationpropertyResolver - PropertyResolver instance, e.g EnvironmentclassValuesAsString - whether to turn Class references into Strings (for
compatibility with AnnotationMetadata or to
preserve them as Class referencesnestedAnnotationsAsMap - whether to turn nested Annotation instances into
AnnotationAttributes maps (for compatibility with
AnnotationMetadata or to preserve them as
Annotation instancesignoreDefaultValue - whether ignore default value or nottryMergedAnnotation - whether try merged annotation or notignoreAttributeNames - the attribute names of annotation should be ignoredannotatedElement can't be found in annotatedElement, return nullpublic static Annotation tryGetMergedAnnotation(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType)
annotationannotatedElement - the annotated elementannotationType - the tyoe pf annotationnullpublic static Annotation tryGetMergedAnnotation(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
annotationannotatedElement - the annotated elementannotationType - the tyoe pf annotationclassValuesAsString - whether to turn Class references into Strings (for
compatibility with AnnotationMetadata or to
preserve them as Class referencesnestedAnnotationsAsMap - whether to turn nested Annotation instances into
AnnotationAttributes maps (for compatibility with
AnnotationMetadata or to preserve them as
Annotation instancesnullpublic static org.springframework.core.annotation.AnnotationAttributes tryGetMergedAnnotationAttributes(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean ignoreDefaultValue, String... ignoreAttributeNames)
the annotation attributes after merging and resolving the placeholdersannotatedElement - the annotated elementannotationType - the tyoe pf annotationpropertyResolver - PropertyResolver instance, e.g EnvironmentignoreDefaultValue - whether ignore default value or notignoreAttributeNames - the attribute names of annotation should be ignorednullpublic static org.springframework.core.annotation.AnnotationAttributes tryGetMergedAnnotationAttributes(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType, org.springframework.core.env.PropertyResolver propertyResolver, boolean classValuesAsString, boolean nestedAnnotationsAsMap, boolean ignoreDefaultValue, String... ignoreAttributeNames)
the annotation attributes after merging and resolving the placeholdersannotatedElement - the annotated elementannotationType - the tyoe pf annotationpropertyResolver - PropertyResolver instance, e.g EnvironmentclassValuesAsString - whether to turn Class references into Strings (for
compatibility with AnnotationMetadata or to
preserve them as Class referencesnestedAnnotationsAsMap - whether to turn nested Annotation instances into
AnnotationAttributes maps (for compatibility with
AnnotationMetadata or to preserve them as
Annotation instancesignoreDefaultValue - whether ignore default value or notignoreAttributeNames - the attribute names of annotation should be ignorednullCopyright © 2020. All rights reserved.