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
Constructors -
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.intmappedSize(ArrayMapNode<K, V> mapping) Called to obtain number of keys in a given mapping.intsize()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
- Specified by:
buildin interfaceIMapBuilder<K,V>
-
clear
Description copied from interface:IMapBuilderDeletes all values. This is useful to reset to build a new map with the same builder.- Specified by:
clearin interfaceIMapBuilder<K,V> - Returns:
- the builder (convenience for chaining multiple calls)
-
add
- Specified by:
addin interfaceIMapBuilder<K,V>
-
size
public int size()- Specified by:
sizein interfaceIMapBuilder<K,V>
-
mappedAssign
Description copied from interface:ArrayAssignMapperCalled during assign operation to create a new mapping for the given key and value.- Specified by:
mappedAssignin 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:ArrayAssignMapperCalled during assign operation to replace an existing mapping for the given key and value.- Specified by:
mappedAssignin 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:ArraySizeMapperCalled to obtain number of keys in a given mapping.- Specified by:
mappedSizein interfaceArraySizeMapper<K>- Parameters:
mapping- mapping to be sized- Returns:
- number of keys in the mapping
-