Interface RequestPredicate
- 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 RequestPredicate
Represents a function that evaluates on a givenServerRequest
. Instances of this function that evaluate on common request properties can be found inRequestPredicates
.- Since:
- 5.0
- Author:
- Arjen Poutsma
- See Also:
RequestPredicates
,RouterFunctions.route(RequestPredicate, HandlerFunction)
,RouterFunctions.nest(RequestPredicate, RouterFunction)
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
accept(RequestPredicates.Visitor visitor)
Accept the given visitor.default RequestPredicate
and(RequestPredicate other)
Return a composed request predicate that tests against both this predicate AND theother
predicate.default RequestPredicate
negate()
Return a predicate that represents the logical negation of this predicate.default Optional<ServerRequest>
nest(ServerRequest request)
Transform the given request into a request used for a nested route.default RequestPredicate
or(RequestPredicate other)
Return a composed request predicate that tests against both this predicate OR theother
predicate.boolean
test(ServerRequest request)
Evaluate this predicate on the given request.
Method Detail
test
boolean test(ServerRequest request)
Evaluate this predicate on the given request.- Parameters:
request
- the request to match against- Returns:
true
if the request matches the predicate;false
otherwise
and
default RequestPredicate and(RequestPredicate other)
Return a composed request predicate that tests against both this predicate AND theother
predicate. When evaluating the composed predicate, if this predicate isfalse
, then theother
predicate is not evaluated.- Parameters:
other
- a predicate that will be logically-ANDed with this predicate- Returns:
- a predicate composed of this predicate AND the
other
predicate
negate
default RequestPredicate negate()
Return a predicate that represents the logical negation of this predicate.- Returns:
- a predicate that represents the logical negation of this predicate
or
default RequestPredicate or(RequestPredicate other)
Return a composed request predicate that tests against both this predicate OR theother
predicate. When evaluating the composed predicate, if this predicate istrue
, then theother
predicate is not evaluated.- Parameters:
other
- a predicate that will be logically-ORed with this predicate- Returns:
- a predicate composed of this predicate OR the
other
predicate
nest
default Optional<ServerRequest> nest(ServerRequest request)
Transform the given request into a request used for a nested route. For instance, a path-based predicate can return aServerRequest
with a the path remaining after a match.The default implementation returns an
Optional
wrapping the given request iftest(ServerRequest)
evaluates totrue
; orOptional.empty()
if it evaluates tofalse
.- Parameters:
request
- the request to be nested- Returns:
- the nested request
- See Also:
RouterFunctions.nest(RequestPredicate, RouterFunction)
accept
default void accept(RequestPredicates.Visitor visitor)
Accept the given visitor. Default implementation callsRequestPredicates.Visitor.unknown(RequestPredicate)
; composedRequestPredicate
implementations are expected to callaccept
for all components that make up this request predicate.- Parameters:
visitor
- the visitor to accept