Class DefaultHeaders<K,V,T extends Headers<K,V,T>>

java.lang.Object
io.netty.handler.codec.DefaultHeaders<K,V,T>
Type Parameters:
K - the type of the header name.
V - the type of the header value.
T - the type to use for return values when the intention is to return this object.
All Implemented Interfaces:
Headers<K,V,T>, Iterable<Map.Entry<K,V>>
Direct Known Subclasses:
CharSequenceMap, CombinedHttpHeaders.CombinedHttpHeadersImpl, DefaultHeadersImpl, DefaultHttp2Headers, DefaultSpdyHeaders, DefaultStompHeaders

public class DefaultHeaders<K,V,T extends Headers<K,V,T>> extends Object implements Headers<K,V,T>
Default implementation of Headers;
  • Field Details

  • Constructor Details

    • DefaultHeaders

      public DefaultHeaders(ValueConverter<V> valueConverter)
    • DefaultHeaders

      public DefaultHeaders(ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator)
    • DefaultHeaders

      public DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter)
    • DefaultHeaders

      public DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator)
    • DefaultHeaders

      public DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator, int arraySizeHint)
      Create a new instance.
      Parameters:
      nameHashingStrategy - Used to hash and equality compare names.
      valueConverter - Used to convert values to/from native types.
      nameValidator - Used to validate name elements.
      arraySizeHint - A hint as to how large the hash data structure should be. The next positive power of two will be used. An upper bound may be enforced.
    • DefaultHeaders

      public DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator, int arraySizeHint, DefaultHeaders.ValueValidator<V> valueValidator)
      Create a new instance.
      Parameters:
      nameHashingStrategy - Used to hash and equality compare names.
      valueConverter - Used to convert values to/from native types.
      nameValidator - Used to validate name elements.
      arraySizeHint - A hint as to how large the hash data structure should be. The next positive power of two will be used. An upper bound may be enforced.
      valueValidator - The validation strategy for entry values.
  • Method Details

    • get

      public V get(K name)
      Description copied from interface: Headers
      Returns the value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      get in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the first header value if the header is found. null if there's no such header
    • get

      public V get(K name, V defaultValue)
      Description copied from interface: Headers
      Returns the value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      get in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the first header value or defaultValue if there is no such header
    • getAndRemove

      public V getAndRemove(K name)
      Description copied from interface: Headers
      Returns the value of a header with the specified name and removes it from this object. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the first header value or null if there is no such header
    • getAndRemove

      public V getAndRemove(K name, V defaultValue)
      Description copied from interface: Headers
      Returns the value of a header with the specified name and removes it from this object. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the first header value or defaultValue if there is no such header
    • getAll

      public List<V> getAll(K name)
      Description copied from interface: Headers
      Returns all values for the header with the specified name. The returned List can't be modified.
      Specified by:
      getAll in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      a List of header values or an empty List if no values are found.
    • valueIterator

      public Iterator<V> valueIterator(K name)
      Equivalent to getAll(Object) but no intermediate list is generated.
      Parameters:
      name - the name of the header to retrieve
      Returns:
      an Iterator of header values corresponding to name.
    • getAllAndRemove

      public List<V> getAllAndRemove(K name)
      Description copied from interface: Headers
      Returns all values for the header with the specified name and removes them from this object. The returned List can't be modified.
      Specified by:
      getAllAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      a List of header values or an empty List if no values are found.
    • contains

      public boolean contains(K name)
      Description copied from interface: Headers
      Returns true if a header with the name exists, false otherwise.
      Specified by:
      contains in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
    • containsObject

      public boolean containsObject(K name, Object value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsObject in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • containsBoolean

      public boolean containsBoolean(K name, boolean value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsBoolean in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • containsByte

      public boolean containsByte(K name, byte value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsByte in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • containsChar

      public boolean containsChar(K name, char value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsChar in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • containsShort

      public boolean containsShort(K name, short value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsShort in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • containsInt

      public boolean containsInt(K name, int value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsInt in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • containsLong

      public boolean containsLong(K name, long value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsLong in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • containsFloat

      public boolean containsFloat(K name, float value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsFloat in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • containsDouble

      public boolean containsDouble(K name, double value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsDouble in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • containsTimeMillis

      public boolean containsTimeMillis(K name, long value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists.
      Specified by:
      containsTimeMillis in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value
      Returns:
      true if it contains it false otherwise
    • contains

      public boolean contains(K name, V value)
      Description copied from interface: Headers
      Returns true if a header with the name and value exists, false otherwise.

      The Object.equals(Object) method is used to test for equality of value.

      Specified by:
      contains in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the header value of the header to find
    • contains

      public final boolean contains(K name, V value, HashingStrategy<? super V> valueHashingStrategy)
    • size

      public int size()
      Description copied from interface: Headers
      Returns the number of headers in this object.
      Specified by:
      size in interface Headers<K,V,T extends Headers<K,V,T>>
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Headers
      Returns true if Headers.size() equals 0.
      Specified by:
      isEmpty in interface Headers<K,V,T extends Headers<K,V,T>>
    • names

      public Set<K> names()
      Description copied from interface: Headers
      Returns a Set of all header names in this object. The returned Set cannot be modified.
      Specified by:
      names in interface Headers<K,V,T extends Headers<K,V,T>>
    • add

      public T add(K name, V value)
      Description copied from interface: Headers
      Adds a new header with the specified name and value.
      Specified by:
      add in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header
      value - the value of the header
      Returns:
      this
    • add

      public T add(K name, Iterable<? extends V> values)
      Description copied from interface: Headers
      Adds new headers with the specified name and values. This method is semantically equivalent to
       for (T value : values) {
           headers.add(name, value);
       }
       
      Specified by:
      add in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      values - the values of the header
      Returns:
      this
    • add

      public T add(K name, V... values)
      Description copied from interface: Headers
      Adds new headers with the specified name and values. This method is semantically equivalent to
       for (T value : values) {
           headers.add(name, value);
       }
       
      Specified by:
      add in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      values - the values of the header
      Returns:
      this
    • addObject

      public T addObject(K name, Object value)
      Description copied from interface: Headers
      Adds a new header. Before the value is added, it's converted to type T.
      Specified by:
      addObject in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • addObject

      public T addObject(K name, Iterable<?> values)
      Description copied from interface: Headers
      Adds a new header with the specified name and values. This method is equivalent to
       for (Object v : values) {
           headers.addObject(name, v);
       }
       
      Specified by:
      addObject in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      values - the value of the header
      Returns:
      this
    • addObject

      public T addObject(K name, Object... values)
      Description copied from interface: Headers
      Adds a new header with the specified name and values. This method is equivalent to
       for (Object v : values) {
           headers.addObject(name, v);
       }
       
      Specified by:
      addObject in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      values - the value of the header
      Returns:
      this
    • addInt

      public T addInt(K name, int value)
      Description copied from interface: Headers
      Adds a new header.
      Specified by:
      addInt in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • addLong

      public T addLong(K name, long value)
      Description copied from interface: Headers
      Adds a new header.
      Specified by:
      addLong in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • addDouble

      public T addDouble(K name, double value)
      Description copied from interface: Headers
      Adds a new header.
      Specified by:
      addDouble in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • addTimeMillis

      public T addTimeMillis(K name, long value)
      Description copied from interface: Headers
      Adds a new header.
      Specified by:
      addTimeMillis in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • addChar

      public T addChar(K name, char value)
      Description copied from interface: Headers
      Adds a new header.
      Specified by:
      addChar in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • addBoolean

      public T addBoolean(K name, boolean value)
      Description copied from interface: Headers
      Adds a new header.
      Specified by:
      addBoolean in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • addFloat

      public T addFloat(K name, float value)
      Description copied from interface: Headers
      Adds a new header.
      Specified by:
      addFloat in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • addByte

      public T addByte(K name, byte value)
      Description copied from interface: Headers
      Adds a new header.
      Specified by:
      addByte in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • addShort

      public T addShort(K name, short value)
      Description copied from interface: Headers
      Adds a new header.
      Specified by:
      addShort in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • add

      public T add(Headers<? extends K,? extends V,?> headers)
      Description copied from interface: Headers
      Adds all header names and values of headers to this object.
      Specified by:
      add in interface Headers<K,V,T extends Headers<K,V,T>>
      Returns:
      this
    • addImpl

      protected void addImpl(Headers<? extends K,? extends V,?> headers)
    • set

      public T set(K name, V value)
      Description copied from interface: Headers
      Sets a header with the specified name and value. Any existing headers with the same name are overwritten.
      Specified by:
      set in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • set

      public T set(K name, Iterable<? extends V> values)
      Description copied from interface: Headers
      Sets a new header with the specified name and values. This method is equivalent to
       for (T v : values) {
           headers.addObject(name, v);
       }
       
      Specified by:
      set in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      values - the value of the header
      Returns:
      this
    • set

      public T set(K name, V... values)
      Description copied from interface: Headers
      Sets a header with the specified name and values. Any existing headers with this name are removed. This method is equivalent to:
       headers.remove(name);
       for (T v : values) {
           headers.add(name, v);
       }
       
      Specified by:
      set in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      values - the value of the header
      Returns:
      this
    • setObject

      public T setObject(K name, Object value)
      Description copied from interface: Headers
      Sets a new header. Any existing headers with this name are removed. Before the value is add, it's converted to type T.
      Specified by:
      setObject in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      value - the value of the header
      Returns:
      this
    • setObject

      public T setObject(K name, Iterable<?> values)
      Description copied from interface: Headers
      Sets a header with the specified name and values. Any existing headers with this name are removed. This method is equivalent to:
       headers.remove(name);
       for (Object v : values) {
           headers.addObject(name, v);
       }
       
      Specified by:
      setObject in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      values - the values of the header
      Returns:
      this
    • setObject

      public T setObject(K name, Object... values)
      Description copied from interface: Headers
      Sets a header with the specified name and values. Any existing headers with this name are removed. This method is equivalent to:
       headers.remove(name);
       for (Object v : values) {
           headers.addObject(name, v);
       }
       
      Specified by:
      setObject in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      values - the values of the header
      Returns:
      this
    • setInt

      public T setInt(K name, int value)
      Description copied from interface: Headers
      Set the name to value. This will remove all previous values associated with name.
      Specified by:
      setInt in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • setLong

      public T setLong(K name, long value)
      Description copied from interface: Headers
      Set the name to value. This will remove all previous values associated with name.
      Specified by:
      setLong in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • setDouble

      public T setDouble(K name, double value)
      Description copied from interface: Headers
      Set the name to value. This will remove all previous values associated with name.
      Specified by:
      setDouble in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • setTimeMillis

      public T setTimeMillis(K name, long value)
      Description copied from interface: Headers
      Set the name to value. This will remove all previous values associated with name.
      Specified by:
      setTimeMillis in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • setFloat

      public T setFloat(K name, float value)
      Description copied from interface: Headers
      Set the name to value. This will remove all previous values associated with name.
      Specified by:
      setFloat in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • setChar

      public T setChar(K name, char value)
      Description copied from interface: Headers
      Set the name to value. This will remove all previous values associated with name.
      Specified by:
      setChar in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • setBoolean

      public T setBoolean(K name, boolean value)
      Description copied from interface: Headers
      Set the name to value. This will remove all previous values associated with name.
      Specified by:
      setBoolean in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • setByte

      public T setByte(K name, byte value)
      Description copied from interface: Headers
      Set the name to value. This will remove all previous values associated with name.
      Specified by:
      setByte in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • setShort

      public T setShort(K name, short value)
      Description copied from interface: Headers
      Set the name to value. This will remove all previous values associated with name.
      Specified by:
      setShort in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • set

      public T set(Headers<? extends K,? extends V,?> headers)
      Description copied from interface: Headers
      Clears the current header entries and copies all header entries of the specified headers.
      Specified by:
      set in interface Headers<K,V,T extends Headers<K,V,T>>
      Returns:
      this
    • setAll

      public T setAll(Headers<? extends K,? extends V,?> headers)
      Description copied from interface: Headers
      Retains all current headers but calls Headers.set(K, V) for each entry in headers.
      Specified by:
      setAll in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      headers - The headers used to Headers.set(K, V) values in this instance
      Returns:
      this
    • remove

      public boolean remove(K name)
      Description copied from interface: Headers
      Removes all headers with the specified name.
      Specified by:
      remove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the header name
      Returns:
      true if at least one entry has been removed.
    • clear

      public T clear()
      Description copied from interface: Headers
      Removes all headers. After a call to this method Headers.size() equals 0.
      Specified by:
      clear in interface Headers<K,V,T extends Headers<K,V,T>>
      Returns:
      this
    • iterator

      public Iterator<Map.Entry<K,V>> iterator()
      Specified by:
      iterator in interface Headers<K,V,T extends Headers<K,V,T>>
      Specified by:
      iterator in interface Iterable<K>
    • getBoolean

      public Boolean getBoolean(K name)
      Description copied from interface: Headers
      Returns the boolean value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getBoolean in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the boolean value of the first value in insertion order or null if there is no such value or it can't be converted to boolean.
    • getBoolean

      public boolean getBoolean(K name, boolean defaultValue)
      Description copied from interface: Headers
      Returns the boolean value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getBoolean in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the boolean value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to boolean.
    • getByte

      public Byte getByte(K name)
      Description copied from interface: Headers
      Returns the byte value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getByte in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the byte value of the first value in insertion order or null if there is no such value or it can't be converted to byte.
    • getByte

      public byte getByte(K name, byte defaultValue)
      Description copied from interface: Headers
      Returns the byte value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getByte in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the byte value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to byte.
    • getChar

      public Character getChar(K name)
      Description copied from interface: Headers
      Returns the char value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getChar in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the char value of the first value in insertion order or null if there is no such value or it can't be converted to char.
    • getChar

      public char getChar(K name, char defaultValue)
      Description copied from interface: Headers
      Returns the char value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getChar in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the char value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to char.
    • getShort

      public Short getShort(K name)
      Description copied from interface: Headers
      Returns the short value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getShort in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the short value of the first value in insertion order or null if there is no such value or it can't be converted to short.
    • getShort

      public short getShort(K name, short defaultValue)
      Description copied from interface: Headers
      Returns the short value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getShort in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the short value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to short.
    • getInt

      public Integer getInt(K name)
      Description copied from interface: Headers
      Returns the int value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getInt in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the int value of the first value in insertion order or null if there is no such value or it can't be converted to int.
    • getInt

      public int getInt(K name, int defaultValue)
      Description copied from interface: Headers
      Returns the int value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getInt in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the int value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to int.
    • getLong

      public Long getLong(K name)
      Description copied from interface: Headers
      Returns the long value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getLong in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the long value of the first value in insertion order or null if there is no such value or it can't be converted to long.
    • getLong

      public long getLong(K name, long defaultValue)
      Description copied from interface: Headers
      Returns the long value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getLong in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the long value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to long.
    • getFloat

      public Float getFloat(K name)
      Description copied from interface: Headers
      Returns the float value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getFloat in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the float value of the first value in insertion order or null if there is no such value or it can't be converted to float.
    • getFloat

      public float getFloat(K name, float defaultValue)
      Description copied from interface: Headers
      Returns the float value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getFloat in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the float value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to float.
    • getDouble

      public Double getDouble(K name)
      Description copied from interface: Headers
      Returns the double value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getDouble in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the double value of the first value in insertion order or null if there is no such value or it can't be converted to double.
    • getDouble

      public double getDouble(K name, double defaultValue)
      Description copied from interface: Headers
      Returns the double value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getDouble in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the double value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to double.
    • getTimeMillis

      public Long getTimeMillis(K name)
      Description copied from interface: Headers
      Returns the value of a header with the specified name in milliseconds. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getTimeMillis in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the milliseconds value of the first value in insertion order or null if there is no such value or it can't be converted to milliseconds.
    • getTimeMillis

      public long getTimeMillis(K name, long defaultValue)
      Description copied from interface: Headers
      Returns the value of a header with the specified name in milliseconds. If there is more than one value for the specified name, the first value in insertion order is returned.
      Specified by:
      getTimeMillis in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the milliseconds value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to milliseconds.
    • getBooleanAndRemove

      public Boolean getBooleanAndRemove(K name)
      Description copied from interface: Headers
      Returns the boolean value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getBooleanAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the boolean value of the first value in insertion order or null if there is no such value or it can't be converted to boolean.
    • getBooleanAndRemove

      public boolean getBooleanAndRemove(K name, boolean defaultValue)
      Description copied from interface: Headers
      Returns the boolean value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getBooleanAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the boolean value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to boolean.
    • getByteAndRemove

      public Byte getByteAndRemove(K name)
      Description copied from interface: Headers
      Returns the byte value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getByteAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      Returns:
      the byte value of the first value in insertion order or null if there is no such value or it can't be converted to byte.
    • getByteAndRemove

      public byte getByteAndRemove(K name, byte defaultValue)
      Description copied from interface: Headers
      Returns the byte value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getByteAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the byte value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to byte.
    • getCharAndRemove

      public Character getCharAndRemove(K name)
      Description copied from interface: Headers
      Returns the char value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getCharAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      Returns:
      the char value of the first value in insertion order or null if there is no such value or it can't be converted to char.
    • getCharAndRemove

      public char getCharAndRemove(K name, char defaultValue)
      Description copied from interface: Headers
      Returns the char value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getCharAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the char value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to char.
    • getShortAndRemove

      public Short getShortAndRemove(K name)
      Description copied from interface: Headers
      Returns the short value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getShortAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      Returns:
      the short value of the first value in insertion order or null if there is no such value or it can't be converted to short.
    • getShortAndRemove

      public short getShortAndRemove(K name, short defaultValue)
      Description copied from interface: Headers
      Returns the short value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getShortAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the short value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to short.
    • getIntAndRemove

      public Integer getIntAndRemove(K name)
      Description copied from interface: Headers
      Returns the int value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getIntAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      Returns:
      the int value of the first value in insertion order or null if there is no such value or it can't be converted to int.
    • getIntAndRemove

      public int getIntAndRemove(K name, int defaultValue)
      Description copied from interface: Headers
      Returns the int value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getIntAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the int value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to int.
    • getLongAndRemove

      public Long getLongAndRemove(K name)
      Description copied from interface: Headers
      Returns the long value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getLongAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      Returns:
      the long value of the first value in insertion order or null if there is no such value or it can't be converted to long.
    • getLongAndRemove

      public long getLongAndRemove(K name, long defaultValue)
      Description copied from interface: Headers
      Returns the long value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getLongAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the long value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to long.
    • getFloatAndRemove

      public Float getFloatAndRemove(K name)
      Description copied from interface: Headers
      Returns the float value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getFloatAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      Returns:
      the float value of the first value in insertion order or null if there is no such value or it can't be converted to float.
    • getFloatAndRemove

      public float getFloatAndRemove(K name, float defaultValue)
      Description copied from interface: Headers
      Returns the float value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getFloatAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the float value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to float.
    • getDoubleAndRemove

      public Double getDoubleAndRemove(K name)
      Description copied from interface: Headers
      Returns the double value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getDoubleAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      Returns:
      the double value of the first value in insertion order or null if there is no such value or it can't be converted to double.
    • getDoubleAndRemove

      public double getDoubleAndRemove(K name, double defaultValue)
      Description copied from interface: Headers
      Returns the double value of a header with the specified name and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getDoubleAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the double value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to double.
    • getTimeMillisAndRemove

      public Long getTimeMillisAndRemove(K name)
      Description copied from interface: Headers
      Returns the value of a header with the specified name in milliseconds and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getTimeMillisAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the milliseconds value of the first value in insertion order or null if there is no such value or it can't be converted to milliseconds.
    • getTimeMillisAndRemove

      public long getTimeMillisAndRemove(K name, long defaultValue)
      Description copied from interface: Headers
      Returns the value of a header with the specified name in milliseconds and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values for name are removed.

      If an exception occurs during the translation from type T all entries with name may still be removed.

      Specified by:
      getTimeMillisAndRemove in interface Headers<K,V,T extends Headers<K,V,T>>
      Parameters:
      name - the name of the header to retrieve
      defaultValue - the default value
      Returns:
      the milliseconds value of the first value in insertion order or defaultValue if there is no such value or it can't be converted to milliseconds.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Headers<K,V,?> h2, HashingStrategy<V> valueHashingStrategy)
      Test this object for equality against h2.
      Parameters:
      h2 - The object to check equality for.
      valueHashingStrategy - Defines how values will be compared for equality.
      Returns:
      true if this object equals h2 given valueHashingStrategy. false otherwise.
    • hashCode

      public final int hashCode(HashingStrategy<V> valueHashingStrategy)
      Generate a hash code for this object given a HashingStrategy to generate hash codes for individual values.
      Parameters:
      valueHashingStrategy - Defines how values will be hashed.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • validateName

      protected void validateName(DefaultHeaders.NameValidator<K> validator, boolean forAdd, K name)
      Call out to the given DefaultHeaders.NameValidator to validate the given name.
      Parameters:
      validator - the validator to use
      forAdd - true if this validation is for adding to the headers, or false if this is for setting (overwriting) the given header.
      name - the name to validate.
    • validateValue

      protected void validateValue(DefaultHeaders.ValueValidator<V> validator, K name, V value)
    • newHeaderEntry

      protected DefaultHeaders.HeaderEntry<K,V> newHeaderEntry(int h, K name, V value, DefaultHeaders.HeaderEntry<K,V> next)
    • valueConverter

      protected ValueConverter<V> valueConverter()
    • nameValidator

      protected DefaultHeaders.NameValidator<K> nameValidator()
    • valueValidator

      protected DefaultHeaders.ValueValidator<V> valueValidator()
    • index

      private int index(int hash)
    • add0

      private void add0(int h, int i, K name, V value)
    • remove0

      private V remove0(int h, int i, K name)
      Returns:
      the first value inserted whose hash code equals h and whose name is equal to name.
    • remove0

    • thisT

      private T thisT()
    • fromObject

      private V fromObject(K name, Object value)
    • fromBoolean

      private V fromBoolean(K name, boolean value)
    • fromByte

      private V fromByte(K name, byte value)
    • fromChar

      private V fromChar(K name, char value)
    • fromShort

      private V fromShort(K name, short value)
    • fromInt

      private V fromInt(K name, int value)
    • fromLong

      private V fromLong(K name, long value)
    • fromFloat

      private V fromFloat(K name, float value)
    • fromDouble

      private V fromDouble(K name, double value)
    • fromTimeMillis

      private V fromTimeMillis(K name, long value)
    • toBoolean

      private boolean toBoolean(K name, V value)
    • toByte

      private byte toByte(K name, V value)
    • toChar

      private char toChar(K name, V value)
    • toShort

      private short toShort(K name, V value)
    • toInt

      private int toInt(K name, V value)
    • toLong

      private long toLong(K name, V value)
    • toFloat

      private float toFloat(K name, V value)
    • toDouble

      private double toDouble(K name, V value)
    • toTimeMillis

      private long toTimeMillis(K name, V value)
    • copy

      public DefaultHeaders<K,V,T> copy()
      Returns a deep copy of this instance.