public final class ProducesRequestCondition extends AbstractRequestCondition<ProducesRequestCondition>
RequestMapping.produces()
and
RequestMapping.headers()
where the header name is 'Accept'.
Regardless of which syntax is used, the semantics are the same.Constructor and Description |
---|
ProducesRequestCondition(java.lang.String... produces)
Creates a new instance from "produces" expressions.
|
ProducesRequestCondition(java.lang.String[] produces,
java.lang.String[] headers)
Creates a new instance with "produces" and "header" expressions.
|
ProducesRequestCondition(java.lang.String[] produces,
java.lang.String[] headers,
RequestedContentTypeResolver resolver)
Same as
ProducesRequestCondition(String[], String[]) but also
accepting a ContentNegotiationManager . |
Modifier and Type | Method and Description |
---|---|
ProducesRequestCondition |
combine(ProducesRequestCondition other)
Returns the "other" instance if it has any expressions; returns "this"
instance otherwise.
|
int |
compareTo(ProducesRequestCondition other,
ServerWebExchange exchange)
Compares this and another "produces" condition as follows:
Sort 'Accept' header media types by quality value via
MediaType.sortByQualityValue(List) and iterate the list. |
protected java.util.List<org.springframework.web.reactive.result.condition.ProducesRequestCondition.ProduceMediaTypeExpression> |
getContent()
Return the discrete items a request condition is composed of.
|
java.util.Set<MediaTypeExpression> |
getExpressions()
Return the contained "produces" expressions.
|
ProducesRequestCondition |
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.
|
java.util.Set<MediaType> |
getProducibleMediaTypes()
Return the contained producible media types excluding negated expressions.
|
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 ProducesRequestCondition(java.lang.String... produces)
produces
- expressions with syntax defined by RequestMapping.produces()
public ProducesRequestCondition(java.lang.String[] produces, java.lang.String[] headers)
produces
- expressions with syntax defined by RequestMapping.produces()
headers
- expressions with syntax defined by RequestMapping.headers()
public ProducesRequestCondition(java.lang.String[] produces, java.lang.String[] headers, RequestedContentTypeResolver resolver)
ProducesRequestCondition(String[], String[])
but also
accepting a ContentNegotiationManager
.produces
- expressions with syntax defined by RequestMapping.produces()
headers
- expressions with syntax defined by RequestMapping.headers()
resolver
- used to determine requested content typepublic java.util.Set<MediaTypeExpression> getExpressions()
public java.util.Set<MediaType> getProducibleMediaTypes()
public boolean isEmpty()
isEmpty
in class AbstractRequestCondition<ProducesRequestCondition>
true
if empty; false
otherwiseprotected java.util.List<org.springframework.web.reactive.result.condition.ProducesRequestCondition.ProduceMediaTypeExpression> getContent()
AbstractRequestCondition
For example URL patterns, HTTP request methods, param expressions, etc.
getContent
in class AbstractRequestCondition<ProducesRequestCondition>
null
protected java.lang.String getToStringInfix()
AbstractRequestCondition
For example " || "
for URL patterns or " && "
for param expressions.
getToStringInfix
in class AbstractRequestCondition<ProducesRequestCondition>
public ProducesRequestCondition combine(ProducesRequestCondition other)
other
- the condition to combine with.@Nullable public ProducesRequestCondition getMatchingCondition(ServerWebExchange exchange)
MediaType.isCompatibleWith(MediaType)
.exchange
- the current exchangenull
if no expressions match.public int compareTo(ProducesRequestCondition other, ServerWebExchange exchange)
MediaType.sortByQualityValue(List)
and iterate the list.
MimeType.equals(Object)
and
then with MediaType.includes(MediaType)
.
MediaType.SPECIFICITY_COMPARATOR
.
It is assumed that both instances have been obtained via
getMatchingCondition(ServerWebExchange)
and each instance
contains the matching producible media type expression only or
is otherwise empty.