Module methanol

Interface HeadersAccumulator<T extends HeadersAccumulator<T>>

  • All Known Implementing Classes:
    MutableRequest, ResponseBuilder

    public interface HeadersAccumulator<T extends HeadersAccumulator<T>>
    An accumulator of header name-value pairs.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      T header​(java.lang.String name, java.lang.String value)
      Adds the given header name-value pair.
      T headers​(java.lang.String... headers)
      Adds each of the given header name-value pairs.
      T headers​(java.net.http.HttpHeaders headers)
      Adds all the given headers.
      T removeHeader​(java.lang.String name)
      Removes all the header values associated with the given name.
      T removeHeaders()
      Removes all the headers added so far.
      T removeHeadersIf​(java.util.function.BiPredicate<java.lang.String,​java.lang.String> filter)
      Removes all the header name-value pairs matched by the given predicate.
      T setHeader​(java.lang.String name, java.lang.String value)
      Sets the header represented by the given name to the given value, overwriting the previous value (if any).
      T setHeader​(java.lang.String name, java.util.List<java.lang.String> values)
      Sets the header represented by the given name to the given values, overwriting the previous value (if any).
      T setHeaderIfAbsent​(java.lang.String name, java.lang.String value)
      Sets the header represented by the given name to the given value, only if there was no header with the given name.
      T setHeaderIfAbsent​(java.lang.String name, java.util.List<java.lang.String> values)
      Sets the header represented by the given name to the given values, only if there was no header with the given name.
    • Method Detail

      • header

        @CanIgnoreReturnValue
        T header​(java.lang.String name,
                 java.lang.String value)
        Adds the given header name-value pair.
        Throws:
        java.lang.IllegalArgumentException - if the given header is invalid
      • headers

        @CanIgnoreReturnValue
        T headers​(java.lang.String... headers)
        Adds each of the given header name-value pairs. The pairs must be appended to each other in the given array, where each name is followed by a corresponding value.
        Throws:
        java.lang.IllegalArgumentException - if any of the given headers is invalid, or the given array has an uneven or non-positive length
      • headers

        @CanIgnoreReturnValue
        T headers​(java.net.http.HttpHeaders headers)
        Adds all the given headers.
      • setHeader

        @CanIgnoreReturnValue
        T setHeader​(java.lang.String name,
                    java.lang.String value)
        Sets the header represented by the given name to the given value, overwriting the previous value (if any).
        Throws:
        java.lang.IllegalArgumentException - if the given header is invalid
      • setHeader

        @CanIgnoreReturnValue
        T setHeader​(java.lang.String name,
                    java.util.List<java.lang.String> values)
        Sets the header represented by the given name to the given values, overwriting the previous value (if any).
        Throws:
        java.lang.IllegalArgumentException - if the given header is invalid
      • setHeaderIfAbsent

        @CanIgnoreReturnValue
        T setHeaderIfAbsent​(java.lang.String name,
                            java.lang.String value)
        Sets the header represented by the given name to the given value, only if there was no header with the given name.
        Throws:
        java.lang.IllegalArgumentException - if the given header is invalid
      • setHeaderIfAbsent

        @CanIgnoreReturnValue
        T setHeaderIfAbsent​(java.lang.String name,
                            java.util.List<java.lang.String> values)
        Sets the header represented by the given name to the given values, only if there was no header with the given name.
        Throws:
        java.lang.IllegalArgumentException - if the given header is invalid
      • removeHeaders

        @CanIgnoreReturnValue
        T removeHeaders()
        Removes all the headers added so far.
      • removeHeader

        @CanIgnoreReturnValue
        T removeHeader​(java.lang.String name)
        Removes all the header values associated with the given name.
      • removeHeadersIf

        @CanIgnoreReturnValue
        T removeHeadersIf​(java.util.function.BiPredicate<java.lang.String,​java.lang.String> filter)
        Removes all the header name-value pairs matched by the given predicate.