org.springframework.web.reactive.result.condition

Class ConsumesRequestCondition

    • Constructor Summary

      Constructors 
      Constructor and Description
      ConsumesRequestCondition(java.lang.String... consumes)
      Creates a new instance from 0 or more "consumes" expressions.
      ConsumesRequestCondition(java.lang.String[] consumes, java.lang.String[] headers)
      Creates a new instance with "consumes" and "header" expressions.
    • Constructor Detail

      • ConsumesRequestCondition

        public ConsumesRequestCondition(java.lang.String... consumes)
        Creates a new instance from 0 or more "consumes" expressions.
        Parameters:
        consumes - expressions with the syntax described in RequestMapping.consumes(); if 0 expressions are provided, the condition will match to every request
      • ConsumesRequestCondition

        public ConsumesRequestCondition(java.lang.String[] consumes,
                                        java.lang.String[] headers)
        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
        Parameters:
        consumes - as described in RequestMapping.consumes()
        headers - as described in RequestMapping.headers()
    • Method Detail

      • getExpressions

        public java.util.Set<MediaTypeExpression> getExpressions()
        Return the contained MediaType expressions.
      • getConsumableMediaTypes

        public java.util.Set<MediaType> getConsumableMediaTypes()
        Returns the media types for this condition excluding negated expressions.
      • getContent

        protected java.util.Collection<org.springframework.web.reactive.result.condition.ConsumesRequestCondition.ConsumeMediaTypeExpression> 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<ConsumesRequestCondition>
        Returns:
        a collection of objects, never null
      • combine

        public ConsumesRequestCondition combine(ConsumesRequestCondition other)
        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.
        Parameters:
        other - the condition to combine with.
        Returns:
        a request condition instance that is the result of combining the two condition instances.
      • getMatchingCondition

        public ConsumesRequestCondition getMatchingCondition(ServerWebExchange exchange)
        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 via MediaType.includes(MediaType).
        Parameters:
        exchange - the current exchange
        Returns:
        the same instance if the condition contains no expressions; or a new condition with matching expressions only; or null if no expressions match.
      • compareTo

        public int compareTo(ConsumesRequestCondition other,
                             ServerWebExchange exchange)
        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(ServerWebExchange) and each instance contains the matching consumable media type expression only or is otherwise empty.