接口 RequestPredicate
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@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
.- 从以下版本开始:
- 5.0
- 作者:
- Arjen Poutsma
- 另请参阅:
RequestPredicates
,RouterFunctions.route(RequestPredicate, HandlerFunction)
,RouterFunctions.nest(RequestPredicate, RouterFunction)
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 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.
方法详细资料
test
boolean test(ServerRequest request)
Evaluate this predicate on the given request.- 参数:
request
- the request to match against- 返回:
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.- 参数:
other
- a predicate that will be logically-ANDed with this predicate- 返回:
- 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.- 返回:
- 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.- 参数:
other
- a predicate that will be logically-ORed with this predicate- 返回:
- 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
.- 参数:
request
- the request to be nested- 返回:
- the nested request
- 另请参阅:
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.- 参数:
visitor
- the visitor to accept