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(String... produces)
Creates a new instance from "produces" expressions.
|
ProducesRequestCondition(String[] produces,
String[] headers)
Creates a new instance with "produces" and "header" expressions.
|
ProducesRequestCondition(String[] produces,
String[] headers,
RequestedContentTypeResolver resolver)
Same as
ProducesRequestCondition(String[], String[]) but also
accepting a ContentNegotiationManager. |
| Modifier and Type | Method and Description |
|---|---|
static void |
clearMediaTypesAttribute(ServerWebExchange exchange)
Use this to clear
MEDIA_TYPES_ATTRIBUTE that contains the parsed,
requested media types. |
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 List<org.springframework.web.reactive.result.condition.ProducesRequestCondition.ProduceMediaTypeExpression> |
getContent()
Return the discrete items a request condition is composed of.
|
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.
|
Set<MediaType> |
getProducibleMediaTypes()
Return the contained producible media types excluding negated expressions.
|
protected String |
getToStringInfix()
The notation to use when printing discrete items of content.
|
boolean |
isEmpty()
Whether the condition has any media type expressions.
|
equals, hashCode, toStringpublic ProducesRequestCondition(String... produces)
produces - expressions with syntax defined by RequestMapping.produces()public ProducesRequestCondition(String[] produces, String[] headers)
produces - expressions with syntax defined by RequestMapping.produces()headers - expressions with syntax defined by RequestMapping.headers()public ProducesRequestCondition(String[] produces, 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 Set<MediaTypeExpression> getExpressions()
public Set<MediaType> getProducibleMediaTypes()
public boolean isEmpty()
isEmpty in class AbstractRequestCondition<ProducesRequestCondition>true if empty; false otherwiseprotected List<org.springframework.web.reactive.result.condition.ProducesRequestCondition.ProduceMediaTypeExpression> getContent()
AbstractRequestConditionFor example URL patterns, HTTP request methods, param expressions, etc.
getContent in class AbstractRequestCondition<ProducesRequestCondition>null)protected String getToStringInfix()
AbstractRequestConditionFor 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.
public static void clearMediaTypesAttribute(ServerWebExchange exchange)
MEDIA_TYPES_ATTRIBUTE that contains the parsed,
requested media types.exchange - the current exchange