Top Description Methods
org.springframework.web.servlet.function

public Interface RequestPredicate

Known Direct Implementers
org.springframework.web.servlet.function.RequestPredicates.RequestModifyingPredicate, org.springframework.web.servlet.function.RequestPredicates.SingleHttpMethodPredicate, org.springframework.web.servlet.function.RequestPredicates.MultipleHttpMethodsPredicate, org.springframework.web.servlet.function.RequestPredicates.HeadersPredicate, org.springframework.web.servlet.function.RequestPredicates.PathExtensionPredicate, org.springframework.web.servlet.function.RequestPredicates.ParamPredicate
Annotations
@FunctionalInterface
Imports
java.util.Optional

Represents a function that evaluates on a given ServerRequest. Instances of this function that evaluate on common request properties can be found in RequestPredicates.
Author
Arjen Poutsma
Since
5.2
See Also
RequestPredicates, RouterFunctions#route(RequestPredicate, HandlerFunction), RouterFunctions#nest(RequestPredicate, RouterFunction)

Method Summary

Modifier and TypeMethod and Description
public default void
accept(RequestPredicates.Visitor
the visitor to accept
visitor
)

Accept the given visitor.

public default RequestPredicate

Returns:

a predicate composed of this predicate AND the other predicate
and
(RequestPredicate
a predicate that will be logically-ANDed with this predicate
other
)

Return a composed request predicate that tests against both this predicate AND the other predicate.

public default RequestPredicate

Returns:

a predicate that represents the logical negation of this predicate
negate
()

Return a predicate that represents the logical negation of this predicate.

public default Optional<ServerRequest>

Returns:

the nested request
nest
(ServerRequest
the request to be nested
request
)

Transform the given request into a request used for a nested route.

public default RequestPredicate

Returns:

a predicate composed of this predicate OR the other predicate
or
(RequestPredicate
a predicate that will be logically-ORed with this predicate
other
)

Return a composed request predicate that tests against both this predicate OR the other predicate.

public boolean

Returns:

true if the request matches the predicate; false otherwise
test
(ServerRequest
the request to match against
request
)

Evaluate this predicate on the given request.

Method Detail

acceptback to summary
public default void accept(RequestPredicates.Visitor visitor)

Accept the given visitor. Default implementation calls RequestPredicates.Visitor#unknown(RequestPredicate); composed RequestPredicate implementations are expected to call accept for all components that make up this request predicate.

Parameters
visitor:RequestPredicates.Visitor

the visitor to accept

andback to summary
public default RequestPredicate and(RequestPredicate other)

Return a composed request predicate that tests against both this predicate AND the other predicate. When evaluating the composed predicate, if this predicate is false, then the other predicate is not evaluated.

Parameters
other:RequestPredicate

a predicate that will be logically-ANDed with this predicate

Returns:RequestPredicate

a predicate composed of this predicate AND the other predicate

negateback to summary
public default RequestPredicate negate()

Return a predicate that represents the logical negation of this predicate.

Returns:RequestPredicate

a predicate that represents the logical negation of this predicate

nestback to summary
public 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 a ServerRequest with a path remaining after a match.

The default implementation returns an Optional wrapping the given request if test(ServerRequest) evaluates to true; or Optional#empty() if it evaluates to false.

Parameters
request:ServerRequest

the request to be nested

Returns:Optional<ServerRequest>

the nested request

See Also
RouterFunctions#nest(RequestPredicate, RouterFunction)
orback to summary
public default RequestPredicate or(RequestPredicate other)

Return a composed request predicate that tests against both this predicate OR the other predicate. When evaluating the composed predicate, if this predicate is true, then the other predicate is not evaluated.

Parameters
other:RequestPredicate

a predicate that will be logically-ORed with this predicate

Returns:RequestPredicate

a predicate composed of this predicate OR the other predicate

testback to summary
public boolean test(ServerRequest request)

Evaluate this predicate on the given request.

Parameters
request:ServerRequest

the request to match against

Returns:boolean

true if the request matches the predicate; false otherwise