Top Description Inners Fields Constructors Methods
io.netty5.handler.codec.http.headers

public abstract Class MultiMap<K, V>

extends Object
Class Inheritance
Known Direct Subclasses
io.netty5.handler.codec.http.headers.DefaultHttpHeaders
Annotations
@UnstableApi
@Internal
Type Parameters
<K>
The type of key.
<V>
The type of value.
Imports
io.netty5.util.internal.UnstableApi, org.jetbrains.annotations.ApiStatus.Internal, .NotNull, .Nullable, java.util.Arrays, .ConcurrentModificationException, .HashSet, .Iterator, .Map, .Map.Entry, .NoSuchElementException, .Set, java.util.function.BiPredicate

A Map like implementation which supports multiple values for a single key.

Implementation Details (subject to change)

This class is designed to store "headers" which are commonly used in protocols to represent meta data. Common protocols typically have the following properties: These requirements make using a Map<K, List<V>> structure prohibitive due to extra allocation and resize operations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
protected abstract class
private class
pack-priv static class
private class
private class

Field Summary

Modifier and TypeField and Description
pack-priv final MultiMap.BucketHead<K, V>[]
private final byte
pack-priv @Nullable MultiMap.BucketHead<K, V>
private int

Constructor Summary

AccessConstructor and Description
pack-priv
MultiMap(final int arraySizeHint)

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
public boolean
contains(final K key, final V value)

pack-priv final boolean
contains(final K key, final V value, final BiPredicate<V, V> valueCompare)

pack-priv final Iterator<Map.Entry<K, V>>
protected abstract boolean

Returns:

true if key1 and key2 are equal.
equals
(K
The first key.
key1
,
K
The second key.
key2
)

Compare key1 and key2 for equality.

public boolean
equals(final Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
protected abstract boolean

Returns:

true if value1 and value2 are equal.
equalsForValue
(V
The first value.
value1
,
V
The second value.
value2
)

Compare value1 and value2 for equality.

pack-priv final Set<K>
pack-priv final V
getValue(final K key)

pack-priv final Iterator<V>
getValues(final K key)

protected abstract int

Returns:

a hash code for key used as an index in this MultiMap.
hashCode
(K
The key to create the hash code for.
key
)

Generate a hash code for key used as an index in this MultiMap.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
protected abstract int

Returns:

a hash code for value using during equality comparisons and hashCode(Object).
hashCodeForValue
(V
the value to generate a hash code for.
value
)

Generate a hash code for value using for equality comparisons and hashCode(Object).

pack-priv final int
index(final int hash)

public final boolean
protected abstract boolean

Returns:

true if the hashCode(Object) and equals(Object, Object) strategy are compatible with multiMap.
isKeyEqualityCompatible
(MultiMap<? extends K, ? extends V>
the MultiMap to compare.
multiMap
)

Determine if the hashCode(Object) and equals(Object, Object) strategy are compatible with multiMap.

private MultiMap.MultiMapEntry<K, V>

Returns:

a new MultiMapEntry to represent an entry in this MultiMap.
newEntry
(K
The key for the MultiMapEntry.
key
,
V
The value for the MultiMapEntry.
value
,
int
The hash code for key.
keyHash
)

Create a new MultiMapEntry to represent an entry in this MultiMap.

pack-priv final void
put(final K key, final V value)

pack-priv final void
putAll(final K key, final Iterable<? extends V> values)

pack-priv final void
putAll(final K key, final V... values)

pack-priv final void
putAll(final MultiMap<? extends K, ? extends V> multiMap)

private void
putAll0(final MultiMap<? extends K, ? extends V> rhs)

private MultiMap.BucketHead<K, V>
putEntry(@Nullable MultiMap.BucketHead<K, V> bucketHead, final int keyHash, final int bucketIndex, final K key, final V value)

private MultiMap.BucketHead<K, V>
putEntry(final int keyHash, final int bucketIndex, final K key, final V value)

pack-priv final void
putExclusive(final K key, final V value)

pack-priv final void
putExclusive(final K key, final Iterable<? extends V> values)

pack-priv final void
putExclusive(final K key, final V... values)

pack-priv final boolean
removeAll(final K key)

private void
removeAll(final K key, final int keyHash, final int bucketIndex)

pack-priv final V
removeAllAndGetFirst(final K key)

pack-priv final void
removeEntry(final @NotNull MultiMap.BucketHead<K, V> bucketHead, final @NotNull MultiMap.MultiMapEntry<K, V> entryToRemove, final int bucketIndex)

public final int
size()

protected abstract K
validateKey(K
The key which will be inserted.
key
,
boolean
true if this validation is for adding to the headers, or false if this is for setting (overwriting) the given header.
forAdd
)

Validate the key before inserting it into this MultiMap.

protected abstract V
validateValue(K
The key for which the value is being inserted, for reference.
key
,
V
The value which will be inserted.
value
)

Validate the value before inserting it into this MultiMap.

pack-priv final Iterator<V>
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait