public final class ConsumesRequestCondition extends AbstractRequestCondition<ConsumesRequestCondition>
RequestMapping.consumes()
and RequestMapping.headers()
where the header name is 'Content-Type'. Regardless of which syntax is
used, the semantics are the same.Constructor and Description |
---|
ConsumesRequestCondition(java.lang.String... consumes)
Creates a new instance from 0 or more "consumes" expressions.
|
ConsumesRequestCondition(java.lang.String[] consumes,
java.lang.String[] headers)
Creates a new instance with "consumes" and "header" expressions.
|
Modifier and Type | Method and Description |
---|---|
ConsumesRequestCondition |
combine(ConsumesRequestCondition other)
Returns the "other" instance if it has any expressions; returns "this"
instance otherwise.
|
int |
compareTo(ConsumesRequestCondition other,
ServerWebExchange exchange)
Returns:
0 if the two conditions have the same number of expressions
Less than 0 if "this" has more or more specific media type expressions
Greater than 0 if "other" has more or more specific media type expressions
|
java.util.Set<MediaType> |
getConsumableMediaTypes()
Returns the media types for this condition excluding negated expressions.
|
protected java.util.Collection<org.springframework.web.reactive.result.condition.ConsumesRequestCondition.ConsumeMediaTypeExpression> |
getContent()
Return the discrete items a request condition is composed of.
|
java.util.Set<MediaTypeExpression> |
getExpressions()
Return the contained MediaType expressions.
|
ConsumesRequestCondition |
getMatchingCondition(ServerWebExchange exchange)
Checks if any of the contained media type expressions match the given
request 'Content-Type' header and returns an instance that is guaranteed
to contain matching expressions only.
|
protected java.lang.String |
getToStringInfix()
The notation to use when printing discrete items of content.
|
boolean |
isEmpty()
Whether the condition has any media type expressions.
|
equals, hashCode, toString
public ConsumesRequestCondition(java.lang.String... consumes)
consumes
- expressions with the syntax described in
RequestMapping.consumes()
; if 0 expressions are provided,
the condition will match to every requestpublic ConsumesRequestCondition(java.lang.String[] consumes, java.lang.String[] headers)
consumes
- as described in RequestMapping.consumes()
headers
- as described in RequestMapping.headers()
public java.util.Set<MediaTypeExpression> getExpressions()
public java.util.Set<MediaType> getConsumableMediaTypes()
public boolean isEmpty()
isEmpty
in class AbstractRequestCondition<ConsumesRequestCondition>
true
if empty; false
otherwiseprotected java.util.Collection<org.springframework.web.reactive.result.condition.ConsumesRequestCondition.ConsumeMediaTypeExpression> getContent()
AbstractRequestCondition
For example URL patterns, HTTP request methods, param expressions, etc.
getContent
in class AbstractRequestCondition<ConsumesRequestCondition>
null
protected java.lang.String getToStringInfix()
AbstractRequestCondition
For example " || "
for URL patterns or " && "
for param expressions.
getToStringInfix
in class AbstractRequestCondition<ConsumesRequestCondition>
public ConsumesRequestCondition combine(ConsumesRequestCondition other)
other
- the condition to combine with.public ConsumesRequestCondition getMatchingCondition(ServerWebExchange exchange)
MediaType.includes(MediaType)
.exchange
- the current exchangenull
if no expressions match.public int compareTo(ConsumesRequestCondition other, ServerWebExchange exchange)
It is assumed that both instances have been obtained via
getMatchingCondition(ServerWebExchange)
and each instance contains
the matching consumable media type expression only or is otherwise empty.