Package org.springframework.web.method
Class HandlerTypePredicate
java.lang.Object
org.springframework.web.method.HandlerTypePredicate
A
Predicate
to match request handling component types if
any of the following selectors match:
- Base packages -- for selecting handlers by their package.
- Assignable types -- for selecting handlers by supertype.
- Annotations -- for selecting handlers annotated in a specific way.
Composability methods on Predicate
can be used :
Predicate<Class<?>> predicate = HandlerTypePredicate.forAnnotation(RestController.class) .and(HandlerTypePredicate.forBasePackage("org.example"));
- Since:
- 5.1
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic HandlerTypePredicate.Builder
builder()
Return a builder for aHandlerTypePredicate
.static HandlerTypePredicate
forAnnotation
(Class<? extends Annotation>... annotations) Match handlers annotated with a specific annotation.static HandlerTypePredicate
Predicate
that applies to any handlers.static HandlerTypePredicate
forAssignableType
(Class<?>... types) Match handlers that are assignable to a given type.static HandlerTypePredicate
forBasePackage
(String... packages) Match handlers declared under a base package, e.g.static HandlerTypePredicate
forBasePackageClass
(Class<?>... packageClasses) Type-safe alternative toforBasePackage(String...)
to specify a base package through a class.boolean
-
Method Details
-
test
-
forAnyHandlerType
Predicate
that applies to any handlers. -
forBasePackage
Match handlers declared under a base package, e.g. "org.example".- Parameters:
packages
- one or more base package names
-
forBasePackageClass
Type-safe alternative toforBasePackage(String...)
to specify a base package through a class.- Parameters:
packageClasses
- one or more base package classes
-
forAssignableType
Match handlers that are assignable to a given type.- Parameters:
types
- one or more handler supertypes
-
forAnnotation
@SafeVarargs public static HandlerTypePredicate forAnnotation(Class<? extends Annotation>... annotations) Match handlers annotated with a specific annotation.- Parameters:
annotations
- one or more annotations to check for
-
builder
Return a builder for aHandlerTypePredicate
.
-