## org.springframework.web.servlet.mvc.condition
Class RequestConditionHolder

    java.lang.Object
      org.springframework.web.servlet.mvc.condition.AbstractRequestCondition<RequestConditionHolder>
          org.springframework.web.servlet.mvc.condition.RequestConditionHolder

All Implemented Interfaces:
  RequestCondition<RequestConditionHolder>

    public final class RequestConditionHolder

extends AbstractRequestCondition<RequestConditionHolder>

A holder for a `RequestCondition` useful when the type of the held request condition is not known ahead of time - e.g. custom condition.

An implementation of `RequestCondition` itself, a `RequestConditionHolder` decorates the held request condition allowing it to be combined and compared with other custom request conditions while ensuring type and null safety.

Since:
  3.1
Author:
  Rossen Stoyanchev

Constructor Summary
`RequestConditionHolder(RequestCondition<?> requestCondition)` Create a new holder to wrap the given request condition.

Method Summary
`RequestConditionHolder` `combine(RequestConditionHolder other)` Combine the request conditions held by the two RequestConditionHolder instances after making sure the conditions are of the same type.
`int` `compareTo(RequestConditionHolder other, HttpServletRequest request)` Compare the request conditions held by the two RequestConditionHolder instances after making sure the conditions are of the same type.
`RequestCondition<?>` `getCondition()` Return the held request condition, or `null` if not holding one.
`protected Collection<?>` `getContent()` Return the discrete items a request condition is composed of.
`RequestConditionHolder` `getMatchingCondition(HttpServletRequest request)` Get the matching condition for the held request condition wrap it in a new RequestConditionHolder instance.
`protected String` `getToStringInfix()` The notation to use when printing discrete items of content.

Methods inherited from class org.springframework.web.servlet.mvc.condition.AbstractRequestCondition
`equals, hashCode, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### RequestConditionHolder

    public RequestConditionHolder(RequestCondition<?> requestCondition)

  Create a new holder to wrap the given request condition.

  Parameters:
    `requestCondition` - the condition to hold, may be `null`

Method Detail

### getCondition

    public RequestCondition<?> getCondition()

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

### getContent

    protected Collection<?> getContent()

  Description copied from class: `AbstractRequestCondition`
  Return the discrete items a request condition is composed of. For example URL patterns, HTTP request methods, param expressions, etc.

  Specified by:
    `getContent` in class `AbstractRequestCondition<RequestConditionHolder>`
  Returns:
    a collection of objects, never `null`

### getToStringInfix

    protected String getToStringInfix()

  Description copied from class: `AbstractRequestCondition`
  The notation to use when printing discrete items of content. For example " || " for URL patterns or " && " for param expressions.

  Specified by:
    `getToStringInfix` in class `AbstractRequestCondition<RequestConditionHolder>`

### combine

    public RequestConditionHolder combine(RequestConditionHolder other)

  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` - the condition to combine with.

### getMatchingCondition

    public RequestConditionHolder getMatchingCondition(HttpServletRequest request)

  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:
    a condition instance in case of a match; or `null` if there is no match.

### compareTo

    public int compareTo(RequestConditionHolder other,
                         HttpServletRequest request)

  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.