public class CompositeRequestCondition extends AbstractRequestCondition<CompositeRequestCondition>
RequestCondition
contract by delegating to multiple
RequestCondition
types and using a logical conjunction (' && '
) to
ensure all conditions match a given request.
When CompositeRequestCondition
instances are combined or compared
they are expected to (a) contain the same number of conditions and (b) that
conditions in the respective index are of the same type. It is acceptable to
provide null
conditions or no conditions at all to the constructor.
Constructor and Description |
---|
CompositeRequestCondition(RequestCondition<?>... requestConditions)
Create an instance with 0 or more
RequestCondition types. |
Modifier and Type | Method and Description |
---|---|
CompositeRequestCondition |
combine(CompositeRequestCondition other)
If one instance is empty, return the other.
|
int |
compareTo(CompositeRequestCondition other,
ServerWebExchange exchange)
If one instance is empty, the other "wins".
|
List<RequestCondition<?>> |
getConditions()
Return the underlying conditions, possibly empty but never
null . |
protected Collection<?> |
getContent()
Return the discrete items a request condition is composed of.
|
CompositeRequestCondition |
getMatchingCondition(ServerWebExchange exchange)
Delegate to all contained conditions to match the request and return the
resulting "matching" condition instances.
|
protected String |
getToStringInfix()
The notation to use when printing discrete items of content.
|
boolean |
isEmpty()
Whether this instance contains 0 conditions or not.
|
equals, hashCode, toString
public CompositeRequestCondition(RequestCondition<?>... requestConditions)
RequestCondition
types. It is
important to create CompositeRequestCondition
instances with the
same number of conditions so they may be compared and combined.
It is acceptable to provide null
conditions.public boolean isEmpty()
isEmpty
in class AbstractRequestCondition<CompositeRequestCondition>
true
if empty; false
otherwisepublic List<RequestCondition<?>> getConditions()
null
.protected Collection<?> getContent()
AbstractRequestCondition
For example URL patterns, HTTP request methods, param expressions, etc.
getContent
in class AbstractRequestCondition<CompositeRequestCondition>
null
)protected String getToStringInfix()
AbstractRequestCondition
For example " || "
for URL patterns or " && "
for param expressions.
getToStringInfix
in class AbstractRequestCondition<CompositeRequestCondition>
public CompositeRequestCondition combine(CompositeRequestCondition other)
other
- the condition to combine with.public CompositeRequestCondition getMatchingCondition(ServerWebExchange exchange)
An empty CompositeRequestCondition
matches to all requests.
null
otherwise.public int compareTo(CompositeRequestCondition other, ServerWebExchange exchange)