Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.result.condition

public final Class HeadersRequestCondition

extends AbstractRequestCondition<HeadersRequestCondition>
Class Inheritance
Imports
java.util.Collection, .Collections, .LinkedHashSet, .Set, org.springframework.lang.Nullable, org.springframework.util.ObjectUtils, org.springframework.web.bind.annotation.RequestMapping, org.springframework.web.cors.reactive.CorsUtils, org.springframework.web.server.ServerWebExchange

A logical conjunction (' && ') request condition that matches a request against a set of header expressions with syntax defined in RequestMapping#headers().

Expressions passed to the constructor with header names 'Accept' or 'Content-Type' are ignored. See ConsumesRequestCondition and ProducesRequestCondition for those.

Author
Rossen Stoyanchev
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
HeadersRequestCondition.HeaderExpression

Parses and matches a single header expression to a request.

Field Summary

Modifier and TypeField and Description
private final Set<HeadersRequestCondition.HeaderExpression>
private static final HeadersRequestCondition

Constructor Summary

AccessConstructor and Description
public
HeadersRequestCondition(String...
media type expressions with syntax defined in RequestMapping#headers(); if 0, the condition will match to every request
headers
)

Create a new instance from the given header expressions.

private

Method Summary

Modifier and TypeMethod and Description
public HeadersRequestCondition
combine(HeadersRequestCondition
the condition to combine with.
other
)

Implements org.springframework.web.reactive.result.condition.RequestCondition.combine.

Returns a new instance with the union of the header expressions from "this" and the "other" instance.

public int
compareTo(HeadersRequestCondition other, ServerWebExchange exchange)

Implements org.springframework.web.reactive.result.condition.RequestCondition.compareTo.

Compare to another condition based on header expressions.

protected Collection<HeadersRequestCondition.HeaderExpression>
getContent()

Implements abstract org.springframework.web.reactive.result.condition.AbstractRequestCondition.getContent.

Return the discrete items a request condition is composed of.

public Set<NameValueExpression<String>>
getExpressions()

Return the contained request header expressions.

public HeadersRequestCondition
getMatchingCondition(ServerWebExchange exchange)

Implements org.springframework.web.reactive.result.condition.RequestCondition.getMatchingCondition.

Returns "this" instance if the request matches all expressions; or null otherwise.

protected String
getToStringInfix()

Implements abstract org.springframework.web.reactive.result.condition.AbstractRequestCondition.getToStringInfix.

The notation to use when printing discrete items of content.

private long
private static Set<HeadersRequestCondition.HeaderExpression>
Inherited from org.springframework.web.reactive.result.condition.AbstractRequestCondition:
equalshashCodeisEmptytoString

Field Detail

expressionsback to summary
private final Set<HeadersRequestCondition.HeaderExpression> expressions
PRE_FLIGHT_MATCHback to summary
private static final HeadersRequestCondition PRE_FLIGHT_MATCH

Constructor Detail

HeadersRequestConditionback to summary
public HeadersRequestCondition(String... headers)

Create a new instance from the given header expressions. Expressions with header names 'Accept' or 'Content-Type' are ignored. See ConsumesRequestCondition and ProducesRequestCondition for those.

Parameters
headers:String[]

media type expressions with syntax defined in RequestMapping#headers(); if 0, the condition will match to every request

HeadersRequestConditionback to summary
private HeadersRequestCondition(Set<HeadersRequestCondition.HeaderExpression> conditions)

Method Detail

combineback to summary
public HeadersRequestCondition combine(HeadersRequestCondition other)

Implements org.springframework.web.reactive.result.condition.RequestCondition.combine.

Returns a new instance with the union of the header expressions from "this" and the "other" instance.

Parameters
other:HeadersRequestCondition

Doc from org.springframework.web.reactive.result.condition.RequestCondition.combine.

the condition to combine with.

Returns:HeadersRequestCondition

Doc from org.springframework.web.reactive.result.condition.RequestCondition.combine.

a request condition instance that is the result of combining the two condition instances.

Annotations
@Override
compareToback to summary
public int compareTo(HeadersRequestCondition other, ServerWebExchange exchange)

Implements org.springframework.web.reactive.result.condition.RequestCondition.compareTo.

Compare to another condition based on header expressions. A condition is considered to be a more specific match, if it has:

  1. A greater number of expressions.
  2. A greater number of non-negated expressions with a concrete value.

It is assumed that both instances have been obtained via getMatchingCondition(ServerWebExchange) and each instance contains the matching header expression only or is otherwise empty.

Annotations
@Override
getContentback to summary
protected Collection<HeadersRequestCondition.HeaderExpression> getContent()

Implements abstract org.springframework.web.reactive.result.condition.AbstractRequestCondition.getContent.

Doc from org.springframework.web.reactive.result.condition.AbstractRequestCondition.getContent.

Return the discrete items a request condition is composed of.

For example URL patterns, HTTP request methods, param expressions, etc.

Returns:Collection<HeadersRequestCondition.HeaderExpression>

a collection of objects (never null)

Annotations
@Override
getExpressionsback to summary
public Set<NameValueExpression<String>> getExpressions()

Return the contained request header expressions.

getMatchingConditionback to summary
public HeadersRequestCondition getMatchingCondition(ServerWebExchange exchange)

Implements org.springframework.web.reactive.result.condition.RequestCondition.getMatchingCondition.

Returns "this" instance if the request matches all expressions; or null otherwise.

Returns:HeadersRequestCondition

Doc from org.springframework.web.reactive.result.condition.RequestCondition.getMatchingCondition.

a condition instance in case of a match or null otherwise.

Annotations
@Override
@Nullable
getToStringInfixback to summary
protected String getToStringInfix()

Implements abstract org.springframework.web.reactive.result.condition.AbstractRequestCondition.getToStringInfix.

Doc from org.springframework.web.reactive.result.condition.AbstractRequestCondition.getToStringInfix.

The notation to use when printing discrete items of content.

For example " || " for URL patterns or " && " for param expressions.

Annotations
@Override
getValueMatchCountback to summary
private long getValueMatchCount(Set<HeadersRequestCondition.HeaderExpression> expressions)
parseExpressionsback to summary
private static Set<HeadersRequestCondition.HeaderExpression> parseExpressions(String... headers)
org.springframework.web.reactive.result.condition back to summary

pack-priv Class HeadersRequestCondition.HeaderExpression

extends AbstractNameValueExpression<String>
Class Inheritance

Parses and matches a single header expression to a request.

Field Summary

Inherited from org.springframework.web.reactive.result.condition.AbstractNameValueExpression:
isNegatednamevalue

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
protected boolean
protected boolean
protected String
Inherited from org.springframework.web.reactive.result.condition.AbstractNameValueExpression:
equalsgetNamegetValuehashCodeisNegatedmatchtoString

Constructor Detail

HeaderExpressionback to summary
public HeaderExpression(String expression)

Method Detail

isCaseSensitiveNameback to summary
protected boolean isCaseSensitiveName()

Implements abstract org.springframework.web.reactive.result.condition.AbstractNameValueExpression.isCaseSensitiveName.

Annotations
@Override
matchNameback to summary
protected boolean matchName(ServerWebExchange exchange)

Implements abstract org.springframework.web.reactive.result.condition.AbstractNameValueExpression.matchName.

Annotations
@Override
matchValueback to summary
protected boolean matchValue(ServerWebExchange exchange)

Implements abstract org.springframework.web.reactive.result.condition.AbstractNameValueExpression.matchValue.

Annotations
@Override
parseValueback to summary
protected String parseValue(String valueExpression)

Implements abstract org.springframework.web.reactive.result.condition.AbstractNameValueExpression.parseValue.

Annotations
@Override