类 ConsumesRequestCondition
java.lang.Object
cn.taketoday.web.handler.condition.AbstractRequestCondition<ConsumesRequestCondition>
cn.taketoday.web.handler.condition.ConsumesRequestCondition
- 所有已实现的接口:
RequestCondition<ConsumesRequestCondition>
public final class ConsumesRequestCondition
extends AbstractRequestCondition<ConsumesRequestCondition>
A logical disjunction (' || ') request condition to match a request's
'Content-Type' header to a list of media type expressions. Two kinds of
media type expressions are supported, which are described in
RequestMapping.consumes() and RequestMapping.headers()
where the header name is 'Content-Type'. Regardless of which syntax is
used, the semantics are the same.- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma, Rossen Stoyanchev, Harry Yang
-
字段概要
字段修饰符和类型字段说明private booleanprivate static final ConsumesRequestConditionprivate final List<MediaTypeExpression> -
构造器概要
构造器限定符构造器说明ConsumesRequestCondition(String... consumes) Creates a new instance from 0 or more "consumes" expressions.ConsumesRequestCondition(String[] consumes, String[] headers) Creates a new instance with "consumes" and "header" expressions.privateConsumesRequestCondition(List<MediaTypeExpression> expressions) Private constructor for internal when creating matching conditions. -
方法概要
修饰符和类型方法说明combine(ConsumesRequestCondition other) Returns the "other" instance if it has any expressions; returns "this" instance otherwise.intcompareTo(ConsumesRequestCondition other, RequestContext request) 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 expressionsReturns the media types for this condition excluding negated expressions.protected Collection<MediaTypeExpression>Return the discrete items a request condition is composed of.Return the contained MediaType expressions.getMatchingCondition(RequestContext 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.private List<MediaTypeExpression>getMatchingExpressions(MediaType contentType) protected StringThe notation to use when printing discrete items of content.private booleanhasBody(RequestContext request) booleanReturn the setting forsetBodyRequired(boolean).booleanisEmpty()Whether the condition has any media type expressions.voidsetBodyRequired(boolean bodyRequired) Whether this condition should expect requests to have a body.从类继承的方法 cn.taketoday.web.handler.condition.AbstractRequestCondition
equals, hashCode, toString
-
字段详细资料
-
EMPTY_CONDITION
-
expressions
-
bodyRequired
private boolean bodyRequired
-
-
构造器详细资料
-
ConsumesRequestCondition
Creates a new instance from 0 or more "consumes" expressions.- 参数:
consumes- expressions with the syntax described inRequestMapping.consumes(); if 0 expressions are provided, the condition will match to every request
-
ConsumesRequestCondition
Creates a new instance with "consumes" and "header" expressions. "Header" expressions where the header name is not 'Content-Type' or have no header value defined are ignored. If 0 expressions are provided in total, the condition will match to every request- 参数:
consumes- as described inRequestMapping.consumes()headers- as described inRequestMapping.headers()
-
ConsumesRequestCondition
Private constructor for internal when creating matching conditions. Note the expressions List is neither sorted nor deep copied.
-
-
方法详细资料
-
getExpressions
Return the contained MediaType expressions. -
getConsumableMediaTypes
Returns the media types for this condition excluding negated expressions. -
isEmpty
public boolean isEmpty()Whether the condition has any media type expressions.- 覆盖:
isEmpty在类中AbstractRequestCondition<ConsumesRequestCondition>- 返回:
trueif empty;falseotherwise
-
getContent
从类复制的说明:AbstractRequestConditionReturn the discrete items a request condition is composed of.For example URL patterns, HTTP request methods, param expressions, etc.
- 指定者:
getContent在类中AbstractRequestCondition<ConsumesRequestCondition>- 返回:
- a collection of objects (never
null)
-
getToStringInfix
从类复制的说明:AbstractRequestConditionThe notation to use when printing discrete items of content.For example
" || "for URL patterns or" && "for param expressions. -
setBodyRequired
public void setBodyRequired(boolean bodyRequired) Whether this condition should expect requests to have a body.By default this is set to
truein which case it is assumed a request body is required and this condition matches to the "Content-Type" header or falls back on "Content-Type: application/octet-stream".If set to
false, and the request does not have a body, then this condition matches automatically, i.e. without checking expressions.- 参数:
bodyRequired- whether requests are expected to have a body
-
isBodyRequired
public boolean isBodyRequired()Return the setting forsetBodyRequired(boolean). -
combine
Returns the "other" instance if it has any expressions; returns "this" instance otherwise. Practically that means a method-level "consumes" overrides a type-level "consumes" condition.- 参数:
other- the condition to combine with.- 返回:
- a request condition instance that is the result of combining the two condition instances.
-
getMatchingCondition
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. The match is performed viaMediaType.includes(MediaType).- 参数:
request- the current request- 返回:
- the same instance if the condition contains no expressions;
or a new condition with matching expressions only;
or
nullif no expressions match
-
hasBody
-
getMatchingExpressions
-
compareTo
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
It is assumed that both instances have been obtained via
getMatchingCondition(RequestContext)and each instance contains the matching consumable media type expression only or is otherwise empty.request- the current request context
-