Class HashMap.Builder<K,V>
java.lang.Object
org.javimmutable.collections.hash.HashMap.Builder<K,V>
- All Implemented Interfaces:
ArrayAssignMapper<K,
,V, ArrayMapNode<K, V>> ArraySizeMapper<ArrayMapNode<K,
,V>> IMapBuilder<K,
V>
@ThreadSafe
public static class HashMap.Builder<K,V>
extends Object
implements IMapBuilder<K,V>, ArrayAssignMapper<K,V,ArrayMapNode<K,V>>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
clear()
Deletes all values.mappedAssign
(K key, V value) Called during assign operation to create a new mapping for the given key and value.mappedAssign
(ArrayMapNode<K, V> current, K key, V value) Called during assign operation to replace an existing mapping for the given key and value.int
mappedSize
(ArrayMapNode<K, V> mapping) Called to obtain number of keys in a given mapping.int
size()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
- Specified by:
build
in interfaceIMapBuilder<K,
V>
-
clear
Description copied from interface:IMapBuilder
Deletes all values. This is useful to reset to build a new map with the same builder.- Specified by:
clear
in interfaceIMapBuilder<K,
V> - Returns:
- the builder (convenience for chaining multiple calls)
-
add
- Specified by:
add
in interfaceIMapBuilder<K,
V>
-
size
public int size()- Specified by:
size
in interfaceIMapBuilder<K,
V>
-
mappedAssign
Description copied from interface:ArrayAssignMapper
Called during assign operation to create a new mapping for the given key and value.- Specified by:
mappedAssign
in interfaceArrayAssignMapper<K,
V, ArrayMapNode<K, V>> - Parameters:
key
- key being assigned tovalue
- value being assigned- Returns:
- non-null mapping
-
mappedAssign
@Nonnull public ArrayMapNode<K,V> mappedAssign(@Nonnull ArrayMapNode<K, V> current, @Nonnull K key, V value) Description copied from interface:ArrayAssignMapper
Called during assign operation to replace an existing mapping for the given key and value.- Specified by:
mappedAssign
in interfaceArrayAssignMapper<K,
V, ArrayMapNode<K, V>> - Parameters:
current
- mapping to be replacedkey
- key being assigned tovalue
- value being assigned- Returns:
- same to keep mapping or non-null to replace mapping
-
mappedSize
Description copied from interface:ArraySizeMapper
Called to obtain number of keys in a given mapping.- Specified by:
mappedSize
in interfaceArraySizeMapper<K>
- Parameters:
mapping
- mapping to be sized- Returns:
- number of keys in the mapping
-