Interface AnnotationFilter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface AnnotationFilter
Callback interface that can be used to filter specific annotation types.Note that the
MergedAnnotationsmodel (which this interface has been designed for) always ignores lang annotations according to thePLAINfilter (for efficiency reasons). Any additional filters and even custom filter implementations apply within this boundary and may only narrow further from here.- Since:
- 5.2
- Author:
- Phillip Webb, Juergen Hoeller
- See Also:
MergedAnnotations
Field Summary
Fields Modifier and Type Field Description static AnnotationFilterALLAnnotationFilterthat always matches and can be used when no relevant annotation types are expected to be present at all.static AnnotationFilterJAVAstatic AnnotationFilterNONEDeprecated.as of 5.2.6 since theMergedAnnotationsmodel always ignores lang annotations according to thePLAINfilter (for efficiency reasons)static AnnotationFilterPLAINAnnotationFilterthat matches annotations in thejava.langandorg.springframework.langpackages and their subpackages.
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanmatches(Annotation annotation)Test if the given annotation matches the filter.default booleanmatches(Class<?> type)Test if the given type matches the filter.booleanmatches(String typeName)Test if the given type name matches the filter.static AnnotationFilterpackages(String... packages)Create a newAnnotationFilterthat matches annotations in the specified packages.
Field Detail
PLAIN
static final AnnotationFilter PLAIN
AnnotationFilterthat matches annotations in thejava.langandorg.springframework.langpackages and their subpackages.This is the default filter in the
MergedAnnotationsmodel.
JAVA
static final AnnotationFilter JAVA
ALL
static final AnnotationFilter ALL
AnnotationFilterthat always matches and can be used when no relevant annotation types are expected to be present at all.
NONE
@Deprecated static final AnnotationFilter NONE
Deprecated.as of 5.2.6 since theMergedAnnotationsmodel always ignores lang annotations according to thePLAINfilter (for efficiency reasons)AnnotationFilterthat never matches and can be used when no filtering is needed (allowing for any annotation types to be present).- See Also:
PLAIN
Method Detail
matches
default boolean matches(Annotation annotation)
Test if the given annotation matches the filter.- Parameters:
annotation- the annotation to test- Returns:
trueif the annotation matches
matches
default boolean matches(Class<?> type)
Test if the given type matches the filter.- Parameters:
type- the annotation type to test- Returns:
trueif the annotation matches
matches
boolean matches(String typeName)
Test if the given type name matches the filter.- Parameters:
typeName- the fully qualified class name of the annotation type to test- Returns:
trueif the annotation matches
packages
static AnnotationFilter packages(String... packages)
Create a newAnnotationFilterthat matches annotations in the specified packages.- Parameters:
packages- the annotation packages that should match- Returns:
- a new
AnnotationFilterinstance