Class DefaultHeaders<K,V,T extends Headers<K,V,T>>
- java.lang.Object
-
- io.netty5.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 returnthis
object.
- Direct Known Subclasses:
CharSequenceMap
,DefaultHeadersImpl
,DefaultHttp2Headers
public class DefaultHeaders<K,V,T extends Headers<K,V,T>> extends Object implements Headers<K,V,T>
Default implementation ofHeaders
;
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DefaultHeaders.HeaderEntry<K,V>
static interface
DefaultHeaders.NameValidator<K>
-
Field Summary
Fields Modifier and Type Field Description protected DefaultHeaders.HeaderEntry<K,V>
head
-
Constructor Summary
Constructors Constructor Description DefaultHeaders(ValueConverter<V> valueConverter)
DefaultHeaders(ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator)
DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter)
DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator)
DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator, int arraySizeHint)
Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
add(Headers<? extends K,? extends V,?> headers)
Adds all header names and values ofheaders
to this object.T
add(K name, Iterable<? extends V> values)
Adds new headers with the specifiedname
andvalues
.T
add(K name, V value)
Adds a new header with the specifiedname
andvalue
.T
add(K name, V... values)
Adds new headers with the specifiedname
andvalues
.T
addBoolean(K name, boolean value)
Adds a new header.T
addByte(K name, byte value)
Adds a new header.T
addChar(K name, char value)
Adds a new header.T
addDouble(K name, double value)
Adds a new header.T
addFloat(K name, float value)
Adds a new header.protected void
addImpl(Headers<? extends K,? extends V,?> headers)
T
addInt(K name, int value)
Adds a new header.T
addLong(K name, long value)
Adds a new header.T
addObject(K name, Iterable<?> values)
Adds a new header with the specified name and values.T
addObject(K name, Object value)
Adds a new header.T
addObject(K name, Object... values)
Adds a new header with the specified name and values.T
addShort(K name, short value)
Adds a new header.T
addTimeMillis(K name, long value)
Adds a new header.T
clear()
Removes all headers.boolean
contains(K name)
Returnstrue
if a header with thename
exists,false
otherwise.boolean
contains(K name, V value)
Returnstrue
if a header with thename
andvalue
exists,false
otherwise.boolean
contains(K name, V value, HashingStrategy<? super V> valueHashingStrategy)
boolean
containsBoolean(K name, boolean value)
Returnstrue
if a header with the name and value exists.boolean
containsByte(K name, byte value)
Returnstrue
if a header with the name and value exists.boolean
containsChar(K name, char value)
Returnstrue
if a header with the name and value exists.boolean
containsDouble(K name, double value)
Returnstrue
if a header with the name and value exists.boolean
containsFloat(K name, float value)
Returnstrue
if a header with the name and value exists.boolean
containsInt(K name, int value)
Returnstrue
if a header with the name and value exists.boolean
containsLong(K name, long value)
Returnstrue
if a header with the name and value exists.boolean
containsObject(K name, Object value)
Returnstrue
if a header with the name and value exists.boolean
containsShort(K name, short value)
Returnstrue
if a header with the name and value exists.boolean
containsTimeMillis(K name, long value)
Returnstrue
if a header with the name and value exists.DefaultHeaders<K,V,T>
copy()
Returns a deep copy of this instance.boolean
equals(Headers<K,V,?> h2, HashingStrategy<V> valueHashingStrategy)
Test this object for equality againsth2
.boolean
equals(Object o)
V
get(K name)
Returns the value of a header with the specified name.V
get(K name, V defaultValue)
Returns the value of a header with the specified name.List<V>
getAll(K name)
Returns all values for the header with the specified name.List<V>
getAllAndRemove(K name)
Returns all values for the header with the specified name and removes them from this object.V
getAndRemove(K name)
Returns the value of a header with the specified name and removes it from this object.V
getAndRemove(K name, V defaultValue)
Returns the value of a header with the specified name and removes it from this object.Boolean
getBoolean(K name)
Returns theboolean
value of a header with the specified name.boolean
getBoolean(K name, boolean defaultValue)
Returns theboolean
value of a header with the specified name.Boolean
getBooleanAndRemove(K name)
Returns theboolean
value of a header with the specifiedname
and removes the header from this object.boolean
getBooleanAndRemove(K name, boolean defaultValue)
Returns theboolean
value of a header with the specifiedname
and removes the header from this object.Byte
getByte(K name)
Returns thebyte
value of a header with the specified name.byte
getByte(K name, byte defaultValue)
Returns thebyte
value of a header with the specified name.Byte
getByteAndRemove(K name)
Returns thebyte
value of a header with the specifiedname
and removes the header from this object.byte
getByteAndRemove(K name, byte defaultValue)
Returns thebyte
value of a header with the specifiedname
and removes the header from this object.Character
getChar(K name)
Returns thechar
value of a header with the specified name.char
getChar(K name, char defaultValue)
Returns thechar
value of a header with the specified name.Character
getCharAndRemove(K name)
Returns thechar
value of a header with the specifiedname
and removes the header from this object.char
getCharAndRemove(K name, char defaultValue)
Returns thechar
value of a header with the specifiedname
and removes the header from this object.Double
getDouble(K name)
Returns thedouble
value of a header with the specified name.double
getDouble(K name, double defaultValue)
Returns thedouble
value of a header with the specified name.Double
getDoubleAndRemove(K name)
Returns thedouble
value of a header with the specifiedname
and removes the header from this object.double
getDoubleAndRemove(K name, double defaultValue)
Returns thedouble
value of a header with the specifiedname
and removes the header from this object.Float
getFloat(K name)
Returns thefloat
value of a header with the specified name.float
getFloat(K name, float defaultValue)
Returns thefloat
value of a header with the specified name.Float
getFloatAndRemove(K name)
Returns thefloat
value of a header with the specifiedname
and removes the header from this object.float
getFloatAndRemove(K name, float defaultValue)
Returns thefloat
value of a header with the specifiedname
and removes the header from this object.Integer
getInt(K name)
Returns theint
value of a header with the specified name.int
getInt(K name, int defaultValue)
Returns theint
value of a header with the specified name.Integer
getIntAndRemove(K name)
Returns theint
value of a header with the specifiedname
and removes the header from this object.int
getIntAndRemove(K name, int defaultValue)
Returns theint
value of a header with the specifiedname
and removes the header from this object.Long
getLong(K name)
Returns thelong
value of a header with the specified name.long
getLong(K name, long defaultValue)
Returns thelong
value of a header with the specified name.Long
getLongAndRemove(K name)
Returns thelong
value of a header with the specifiedname
and removes the header from this object.long
getLongAndRemove(K name, long defaultValue)
Returns thelong
value of a header with the specifiedname
and removes the header from this object.Short
getShort(K name)
Returns theshort
value of a header with the specified name.short
getShort(K name, short defaultValue)
Returns theshort
value of a header with the specified name.Short
getShortAndRemove(K name)
Returns theshort
value of a header with the specifiedname
and removes the header from this object.short
getShortAndRemove(K name, short defaultValue)
Returns theshort
value of a header with the specifiedname
and removes the header from this object.Long
getTimeMillis(K name)
Returns the value of a header with the specified name in milliseconds.long
getTimeMillis(K name, long defaultValue)
Returns the value of a header with the specified name in milliseconds.Long
getTimeMillisAndRemove(K name)
Returns the value of a header with the specifiedname
in milliseconds and removes the header from this object.long
getTimeMillisAndRemove(K name, long defaultValue)
Returns the value of a header with the specifiedname
in milliseconds and removes the header from this object.int
hashCode()
int
hashCode(HashingStrategy<V> valueHashingStrategy)
Generate a hash code for this object given aHashingStrategy
to generate hash codes for individual values.boolean
isEmpty()
Iterator<Map.Entry<K,V>>
iterator()
Set<K>
names()
Returns aSet
of all header names in this object.protected DefaultHeaders.HeaderEntry<K,V>
newHeaderEntry(int h, K name, V value, DefaultHeaders.HeaderEntry<K,V> next)
boolean
remove(K name)
Removes all headers with the specifiedname
.T
set(Headers<? extends K,? extends V,?> headers)
Clears the current header entries and copies all header entries of the specifiedheaders
.T
set(K name, Iterable<? extends V> values)
Sets a new header with the specified name and values.T
set(K name, V value)
Sets a header with the specified name and value.T
set(K name, V... values)
Sets a header with the specified name and values.T
setAll(Headers<? extends K,? extends V,?> headers)
Retains all current headers but calls#set(K, V)
for each entry inheaders
.T
setBoolean(K name, boolean value)
Set thename
tovalue
.T
setByte(K name, byte value)
Set thename
tovalue
.T
setChar(K name, char value)
Set thename
tovalue
.T
setDouble(K name, double value)
Set thename
tovalue
.T
setFloat(K name, float value)
Set thename
tovalue
.T
setInt(K name, int value)
Set thename
tovalue
.T
setLong(K name, long value)
Set thename
tovalue
.T
setObject(K name, Iterable<?> values)
Sets a header with the specified name and values.T
setObject(K name, Object value)
Sets a new header.T
setObject(K name, Object... values)
Sets a header with the specified name and values.T
setShort(K name, short value)
Set thename
tovalue
.T
setTimeMillis(K name, long value)
Set thename
tovalue
.int
size()
Returns the number of headers in this object.String
toString()
protected ValueConverter<V>
valueConverter()
Iterator<V>
valueIterator(K name)
Equivalent togetAll(Object)
but no intermediate list is generated.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
head
protected final DefaultHeaders.HeaderEntry<K,V> head
-
-
Constructor Detail
-
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.
-
-
Method Detail
-
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.
-
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.
-
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.
-
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.
-
getAll
public List<V> getAll(K name)
Description copied from interface:Headers
Returns all values for the header with the specified name. The returnedList
can't be modified.
-
valueIterator
public Iterator<V> valueIterator(K name)
Equivalent togetAll(Object)
but no intermediate list is generated.- Parameters:
name
- the name of the header to retrieve- Returns:
- an
Iterator
of header values corresponding toname
.
-
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 returnedList
can't be modified.
-
contains
public boolean contains(K name)
Description copied from interface:Headers
Returnstrue
if a header with thename
exists,false
otherwise.
-
containsObject
public boolean containsObject(K name, Object value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
containsBoolean
public boolean containsBoolean(K name, boolean value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
containsByte
public boolean containsByte(K name, byte value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
containsChar
public boolean containsChar(K name, char value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
containsShort
public boolean containsShort(K name, short value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
containsInt
public boolean containsInt(K name, int value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
containsLong
public boolean containsLong(K name, long value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
containsFloat
public boolean containsFloat(K name, float value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
containsDouble
public boolean containsDouble(K name, double value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
containsTimeMillis
public boolean containsTimeMillis(K name, long value)
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists.
-
contains
public boolean contains(K name, V value)
Description copied from interface:Headers
Returnstrue
if a header with thename
andvalue
exists,false
otherwise.The
Object.equals(Object)
method is used to test for equality ofvalue
.
-
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.
-
isEmpty
public boolean isEmpty()
Description copied from interface:Headers
-
add
public T add(K name, V value)
Description copied from interface:Headers
Adds a new header with the specifiedname
andvalue
.
-
add
public T add(K name, Iterable<? extends V> values)
Description copied from interface:Headers
Adds new headers with the specifiedname
andvalues
. This method is semantically equivalent tofor (T value : values) { headers.add(name, value); }
-
add
public T add(K name, V... values)
Description copied from interface:Headers
Adds new headers with the specifiedname
andvalues
. This method is semantically equivalent tofor (T value : values) { headers.add(name, value); }
-
addObject
public T addObject(K name, Object value)
Description copied from interface:Headers
Adds a new header. Before thevalue
is added, it's converted to typeT
.
-
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 tofor (Object v : values) { headers.addObject(name, v); }
-
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 tofor (Object v : values) { headers.addObject(name, v); }
-
addInt
public T addInt(K name, int value)
Description copied from interface:Headers
Adds a new header.
-
addLong
public T addLong(K name, long value)
Description copied from interface:Headers
Adds a new header.
-
addDouble
public T addDouble(K name, double value)
Description copied from interface:Headers
Adds a new header.
-
addTimeMillis
public T addTimeMillis(K name, long value)
Description copied from interface:Headers
Adds a new header.
-
addChar
public T addChar(K name, char value)
Description copied from interface:Headers
Adds a new header.
-
addBoolean
public T addBoolean(K name, boolean value)
Description copied from interface:Headers
Adds a new header.
-
addFloat
public T addFloat(K name, float value)
Description copied from interface:Headers
Adds a new header.
-
addByte
public T addByte(K name, byte value)
Description copied from interface:Headers
Adds a new header.
-
addShort
public T addShort(K name, short value)
Description copied from interface:Headers
Adds a new header.
-
add
public T add(Headers<? extends K,? extends V,?> headers)
Description copied from interface:Headers
Adds all header names and values ofheaders
to this object.
-
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.
-
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 tofor (T v : values) { headers.addObject(name, v); }
-
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); }
-
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 thevalue
is add, it's converted to typeT
.
-
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); }
-
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); }
-
setInt
public T setInt(K name, int value)
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
.
-
setLong
public T setLong(K name, long value)
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
.
-
setDouble
public T setDouble(K name, double value)
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
.
-
setTimeMillis
public T setTimeMillis(K name, long value)
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
.
-
setFloat
public T setFloat(K name, float value)
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
.
-
setChar
public T setChar(K name, char value)
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
.
-
setBoolean
public T setBoolean(K name, boolean value)
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
.
-
setByte
public T setByte(K name, byte value)
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
.
-
setShort
public T setShort(K name, short value)
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
.
-
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 specifiedheaders
.
-
setAll
public T setAll(Headers<? extends K,? extends V,?> headers)
Description copied from interface:Headers
Retains all current headers but calls#set(K, V)
for each entry inheaders
.
-
remove
public boolean remove(K name)
Description copied from interface:Headers
Removes all headers with the specifiedname
.
-
clear
public T clear()
Description copied from interface:Headers
Removes all headers. After a call to this methodHeaders.size()
equals0
.
-
getBoolean
public Boolean getBoolean(K name)
Description copied from interface:Headers
Returns theboolean
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.
-
getBoolean
public boolean getBoolean(K name, boolean defaultValue)
Description copied from interface:Headers
Returns theboolean
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 interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
boolean
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toboolean
.
-
getByte
public Byte getByte(K name)
Description copied from interface:Headers
Returns thebyte
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.
-
getByte
public byte getByte(K name, byte defaultValue)
Description copied from interface:Headers
Returns thebyte
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 interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
byte
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tobyte
.
-
getChar
public Character getChar(K name)
Description copied from interface:Headers
Returns thechar
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.
-
getChar
public char getChar(K name, char defaultValue)
Description copied from interface:Headers
Returns thechar
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 interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
char
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tochar
.
-
getShort
public Short getShort(K name)
Description copied from interface:Headers
Returns theshort
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.
-
getShort
public short getShort(K name, short defaultValue)
Description copied from interface:Headers
Returns theshort
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 interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
short
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toshort
.
-
getInt
public Integer getInt(K name)
Description copied from interface:Headers
Returns theint
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.
-
getInt
public int getInt(K name, int defaultValue)
Description copied from interface:Headers
Returns theint
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.
-
getLong
public Long getLong(K name)
Description copied from interface:Headers
Returns thelong
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.
-
getLong
public long getLong(K name, long defaultValue)
Description copied from interface:Headers
Returns thelong
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 interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
long
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tolong
.
-
getFloat
public Float getFloat(K name)
Description copied from interface:Headers
Returns thefloat
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.
-
getFloat
public float getFloat(K name, float defaultValue)
Description copied from interface:Headers
Returns thefloat
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 interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
float
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tofloat
.
-
getDouble
public Double getDouble(K name)
Description copied from interface:Headers
Returns thedouble
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.
-
getDouble
public double getDouble(K name, double defaultValue)
Description copied from interface:Headers
Returns thedouble
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 interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
double
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted todouble
.
-
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.
-
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 interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to retrievedefaultValue
- 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 theboolean
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.
-
getBooleanAndRemove
public boolean getBooleanAndRemove(K name, boolean defaultValue)
Description copied from interface:Headers
Returns theboolean
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getBooleanAndRemove
in interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
boolean
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toboolean
.
-
getByteAndRemove
public Byte getByteAndRemove(K name)
Description copied from interface:Headers
Returns thebyte
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.
-
getByteAndRemove
public byte getByteAndRemove(K name, byte defaultValue)
Description copied from interface:Headers
Returns thebyte
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getByteAndRemove
in interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
byte
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tobyte
.
-
getCharAndRemove
public Character getCharAndRemove(K name)
Description copied from interface:Headers
Returns thechar
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.
-
getCharAndRemove
public char getCharAndRemove(K name, char defaultValue)
Description copied from interface:Headers
Returns thechar
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getCharAndRemove
in interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
char
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tochar
.
-
getShortAndRemove
public Short getShortAndRemove(K name)
Description copied from interface:Headers
Returns theshort
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.
-
getShortAndRemove
public short getShortAndRemove(K name, short defaultValue)
Description copied from interface:Headers
Returns theshort
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getShortAndRemove
in interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
short
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toshort
.
-
getIntAndRemove
public Integer getIntAndRemove(K name)
Description copied from interface:Headers
Returns theint
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.
-
getIntAndRemove
public int getIntAndRemove(K name, int defaultValue)
Description copied from interface:Headers
Returns theint
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getIntAndRemove
in interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
int
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toint
.
-
getLongAndRemove
public Long getLongAndRemove(K name)
Description copied from interface:Headers
Returns thelong
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.
-
getLongAndRemove
public long getLongAndRemove(K name, long defaultValue)
Description copied from interface:Headers
Returns thelong
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getLongAndRemove
in interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
long
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tolong
.
-
getFloatAndRemove
public Float getFloatAndRemove(K name)
Description copied from interface:Headers
Returns thefloat
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.
-
getFloatAndRemove
public float getFloatAndRemove(K name, float defaultValue)
Description copied from interface:Headers
Returns thefloat
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getFloatAndRemove
in interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
float
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tofloat
.
-
getDoubleAndRemove
public Double getDoubleAndRemove(K name)
Description copied from interface:Headers
Returns thedouble
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.
-
getDoubleAndRemove
public double getDoubleAndRemove(K name, double defaultValue)
Description copied from interface:Headers
Returns thedouble
value of a header with the specifiedname
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 forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getDoubleAndRemove
in interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
double
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted todouble
.
-
getTimeMillisAndRemove
public Long getTimeMillisAndRemove(K name)
Description copied from interface:Headers
Returns the value of a header with the specifiedname
in milliseconds and removes the header from this object. If there is more than one value for the specifiedname
, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.
-
getTimeMillisAndRemove
public long getTimeMillisAndRemove(K name, long defaultValue)
Description copied from interface:Headers
Returns the value of a header with the specifiedname
in milliseconds and removes the header from this object. If there is more than one value for the specifiedname
, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getTimeMillisAndRemove
in interfaceHeaders<K,V,T extends Headers<K,V,T>>
- Parameters:
name
- the name of the header to retrievedefaultValue
- 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 final boolean equals(Headers<K,V,?> h2, HashingStrategy<V> valueHashingStrategy)
Test this object for equality againsth2
.- Parameters:
h2
- The object to check equality for.valueHashingStrategy
- Defines how values will be compared for equality.- Returns:
true
if this object equalsh2
givenvalueHashingStrategy
.false
otherwise.
-
hashCode
public final int hashCode(HashingStrategy<V> valueHashingStrategy)
Generate a hash code for this object given aHashingStrategy
to generate hash codes for individual values.- Parameters:
valueHashingStrategy
- Defines how values will be hashed.
-
newHeaderEntry
protected DefaultHeaders.HeaderEntry<K,V> newHeaderEntry(int h, K name, V value, DefaultHeaders.HeaderEntry<K,V> next)
-
valueConverter
protected ValueConverter<V> valueConverter()
-
copy
public DefaultHeaders<K,V,T> copy()
Returns a deep copy of this instance.
-
-