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,
ContentNegotiationManager manager)
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,
HttpServletRequest request)
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.servlet.mvc.condition.ProducesRequestCondition.ProduceMediaTypeExpression> |
getContent()
Return the discrete items a request condition is composed of.
|
Set<MediaTypeExpression> |
getExpressions()
Return the contained "produces" expressions.
|
ProducesRequestCondition |
getMatchingCondition(HttpServletRequest request)
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, toString
public ProducesRequestCondition(String... produces)
produces
- expressions with syntax defined by RequestMapping.produces()
public ProducesRequestCondition(String[] produces, @Nullable String[] headers)
produces
- expressions with syntax defined by RequestMapping.produces()
headers
- expressions with syntax defined by RequestMapping.headers()
public ProducesRequestCondition(String[] produces, @Nullable String[] headers, @Nullable ContentNegotiationManager manager)
ProducesRequestCondition(String[], String[])
but also
accepting a ContentNegotiationManager
.produces
- expressions with syntax defined by RequestMapping.produces()
headers
- expressions with syntax defined by RequestMapping.headers()
manager
- used to determine requested media typespublic Set<MediaTypeExpression> getExpressions()
public Set<MediaType> getProducibleMediaTypes()
public boolean isEmpty()
isEmpty
in class AbstractRequestCondition<ProducesRequestCondition>
true
if empty; false
otherwiseprotected List<org.springframework.web.servlet.mvc.condition.ProducesRequestCondition.ProduceMediaTypeExpression> getContent()
AbstractRequestCondition
For example URL patterns, HTTP request methods, param expressions, etc.
getContent
in class AbstractRequestCondition<ProducesRequestCondition>
null
)protected 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(HttpServletRequest request)
MediaType.isCompatibleWith(MediaType)
.request
- the current requestnull
if no expressions match.public int compareTo(ProducesRequestCondition other, HttpServletRequest request)
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(HttpServletRequest)
and each instance
contains the matching producible media type expression only or
is otherwise empty.