public final class HeadersRequestCondition extends AbstractRequestCondition<HeadersRequestCondition>
RequestMapping.headers()
.
Expressions passed to the constructor with header names 'Accept' or
'Content-Type' are ignored. See ConsumesRequestCondition
and
ProducesRequestCondition
for those.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
HeadersRequestCondition.HeaderExpression
Parses and matches a single header expression to a request.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Set<HeadersRequestCondition.HeaderExpression> |
expressions |
Modifier | Constructor and Description |
---|---|
private |
HeadersRequestCondition(java.util.Collection<HeadersRequestCondition.HeaderExpression> conditions) |
|
HeadersRequestCondition(java.lang.String... headers)
Create a new instance from the given header expressions.
|
Modifier and Type | Method and Description |
---|---|
HeadersRequestCondition |
combine(HeadersRequestCondition other)
Returns a new instance with the union of the header expressions
from "this" and the "other" instance.
|
int |
compareTo(HeadersRequestCondition other,
HttpServletRequest request)
Returns:
0 if the two conditions have the same number of header expressions
Less than 0 if "this" instance has more header expressions
Greater than 0 if the "other" instance has more header expressions
|
protected java.util.Collection<HeadersRequestCondition.HeaderExpression> |
getContent()
Return the discrete items a request condition is composed of.
|
java.util.Set<NameValueExpression<java.lang.String>> |
getExpressions()
Return the contained request header expressions.
|
HeadersRequestCondition |
getMatchingCondition(HttpServletRequest request)
Returns "this" instance if the request matches all expressions;
or
null otherwise. |
protected java.lang.String |
getToStringInfix()
The notation to use when printing discrete items of content.
|
private static java.util.Collection<HeadersRequestCondition.HeaderExpression> |
parseExpressions(java.lang.String... headers) |
equals, hashCode, toString
private final java.util.Set<HeadersRequestCondition.HeaderExpression> expressions
public HeadersRequestCondition(java.lang.String... headers)
ConsumesRequestCondition
and ProducesRequestCondition
for those.headers
- media type expressions with syntax defined in RequestMapping.headers()
;
if 0, the condition will match to every requestprivate HeadersRequestCondition(java.util.Collection<HeadersRequestCondition.HeaderExpression> conditions)
private static java.util.Collection<HeadersRequestCondition.HeaderExpression> parseExpressions(java.lang.String... headers)
public java.util.Set<NameValueExpression<java.lang.String>> getExpressions()
protected java.util.Collection<HeadersRequestCondition.HeaderExpression> getContent()
AbstractRequestCondition
getContent
in class AbstractRequestCondition<HeadersRequestCondition>
null
protected java.lang.String getToStringInfix()
AbstractRequestCondition
getToStringInfix
in class AbstractRequestCondition<HeadersRequestCondition>
public HeadersRequestCondition combine(HeadersRequestCondition other)
other
- the condition to combine with.public HeadersRequestCondition getMatchingCondition(HttpServletRequest request)
null
otherwise.null
if there is no matchpublic int compareTo(HeadersRequestCondition other, HttpServletRequest request)
It is assumed that both instances have been obtained via
getMatchingCondition(HttpServletRequest)
and each instance
contains the matching header expression only or is otherwise empty.