Top Description Fields Constructors Methods
org.springframework.web.servlet.mvc.condition

public final Class RequestConditionHolder

extends AbstractRequestCondition<RequestConditionHolder>
Class Inheritance
Imports
java.util.Collection, .Collections, jakarta.servlet.http.HttpServletRequest, org.springframework.lang.Nullable

A holder for a RequestCondition useful when the type of the request condition is not known ahead of time, e.g. custom condition. Since this class is also an implementation of RequestCondition, effectively it decorates the held request condition and allows it to be combined and compared with other request conditions in a type and null safe way.

When two RequestConditionHolder instances are combined or compared with each other, it is expected the conditions they hold are of the same type. If they are not, a ClassCastException is raised.

Author
Rossen Stoyanchev
Since
3.1

Field Summary

Modifier and TypeField and Description
private final RequestCondition<Object>

Constructor Summary

AccessConstructor and Description
public
RequestConditionHolder(RequestCondition<?>
the condition to hold, may be null
requestCondition
)

Create a new holder to wrap the given request condition.

Method Summary

Modifier and TypeMethod and Description
private void
assertEqualConditionTypes(RequestCondition<?> thisCondition, RequestCondition<?> otherCondition)

Ensure the held request conditions are of the same type.

public RequestConditionHolder
combine(RequestConditionHolder
the condition to combine with.
other
)

Implements org.springframework.web.servlet.mvc.condition.RequestCondition.combine.

Combine the request conditions held by the two RequestConditionHolder instances after making sure the conditions are of the same type.

public int
compareTo(RequestConditionHolder other, HttpServletRequest request)

Implements org.springframework.web.servlet.mvc.condition.RequestCondition.compareTo.

Compare the request conditions held by the two RequestConditionHolder instances after making sure the conditions are of the same type.

public RequestCondition<?>
getCondition()

Return the held request condition, or null if not holding one.

protected Collection<?>
getContent()

Implements abstract org.springframework.web.servlet.mvc.condition.AbstractRequestCondition.getContent.

Return the discrete items a request condition is composed of.

public RequestConditionHolder
getMatchingCondition(HttpServletRequest request)

Implements org.springframework.web.servlet.mvc.condition.RequestCondition.getMatchingCondition.

Get the matching condition for the held request condition wrap it in a new RequestConditionHolder instance.

protected String
getToStringInfix()

Implements abstract org.springframework.web.servlet.mvc.condition.AbstractRequestCondition.getToStringInfix.

The notation to use when printing discrete items of content.

Inherited from org.springframework.web.servlet.mvc.condition.AbstractRequestCondition:
equalshashCodeisEmptytoString

Field Detail

conditionback to summary
private final RequestCondition<Object> condition
Annotations
@Nullable

Constructor Detail

RequestConditionHolderback to summary
public RequestConditionHolder(RequestCondition<?> requestCondition)

Create a new holder to wrap the given request condition.

Parameters
requestCondition:RequestCondition<?>

the condition to hold, may be null

Annotations
@SuppressWarnings:unchecked

Method Detail

assertEqualConditionTypesback to summary
private void assertEqualConditionTypes(RequestCondition<?> thisCondition, RequestCondition<?> otherCondition)

Ensure the held request conditions are of the same type.

combineback to summary
public RequestConditionHolder combine(RequestConditionHolder other)

Implements org.springframework.web.servlet.mvc.condition.RequestCondition.combine.

Combine the request conditions held by the two RequestConditionHolder instances after making sure the conditions are of the same type. Or if one holder is empty, the other holder is returned.

Parameters
other:RequestConditionHolder

Doc from org.springframework.web.servlet.mvc.condition.RequestCondition.combine.

the condition to combine with.

Returns:RequestConditionHolder

Doc from org.springframework.web.servlet.mvc.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(RequestConditionHolder other, HttpServletRequest request)

Implements org.springframework.web.servlet.mvc.condition.RequestCondition.compareTo.

Compare the request conditions held by the two RequestConditionHolder instances after making sure the conditions are of the same type. Or if one holder is empty, the other holder is preferred.

Annotations
@Override
getConditionback to summary
public RequestCondition<?> getCondition()

Return the held request condition, or null if not holding one.

Annotations
@Nullable
getContentback to summary
protected Collection<?> getContent()

Implements abstract org.springframework.web.servlet.mvc.condition.AbstractRequestCondition.getContent.

Doc from org.springframework.web.servlet.mvc.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<?>

a collection of objects (never null)

Annotations
@Override
getMatchingConditionback to summary
public RequestConditionHolder getMatchingCondition(HttpServletRequest request)

Implements org.springframework.web.servlet.mvc.condition.RequestCondition.getMatchingCondition.

Get the matching condition for the held request condition wrap it in a new RequestConditionHolder instance. Or otherwise if this is an empty holder, return the same holder instance.

Returns:RequestConditionHolder

Doc from org.springframework.web.servlet.mvc.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.servlet.mvc.condition.AbstractRequestCondition.getToStringInfix.

Doc from org.springframework.web.servlet.mvc.condition.AbstractRequestCondition.getToStringInfix.

The notation to use when printing discrete items of content.

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

Annotations
@Override