Module org.omnifaces
Class ConcurrentLinkedHashMap.Builder<K,V>
- java.lang.Object
-
- org.omnifaces.util.concurrentlinkedhashmap.ConcurrentLinkedHashMap.Builder<K,V>
-
- Enclosing class:
- ConcurrentLinkedHashMap<K,V>
public static final class ConcurrentLinkedHashMap.Builder<K,V> extends Object
A builder that createsConcurrentLinkedHashMap
instances. It provides a flexible approach for constructing customized instances with a named parameter syntax. It can be used in the following manner:ConcurrentMap<Vertex, Set<Edge>> graph = new Builder<Vertex, Set<Edge>>() .maximumWeightedCapacity(5000) .build();
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConcurrentLinkedHashMap<K,V>
build()
Creates a newConcurrentLinkedHashMap
instance.ConcurrentLinkedHashMap.Builder<K,V>
concurrencyLevel(int concurrencyLevel)
Specifies the estimated number of concurrently updating threads.ConcurrentLinkedHashMap.Builder<K,V>
initialCapacity(int initialCapacity)
Specifies the initial capacity of the hash table (default16
).ConcurrentLinkedHashMap.Builder<K,V>
listener(EvictionListener<K,V> listener)
Specifies an optional listener that is registered for notification when an entry is evicted.ConcurrentLinkedHashMap.Builder<K,V>
maximumWeightedCapacity(long capacity)
Specifies the maximum weighted capacity to coerce the map to and may exceed it temporarily.
-
-
-
Method Detail
-
initialCapacity
public ConcurrentLinkedHashMap.Builder<K,V> initialCapacity(int initialCapacity)
Specifies the initial capacity of the hash table (default16
). This is the number of key-value pairs that the hash table can hold before a resize operation is required.- Parameters:
initialCapacity
- the initial capacity used to size the hash table to accommodate this many entries.- Throws:
IllegalArgumentException
- if the initialCapacity is negative
-
maximumWeightedCapacity
public ConcurrentLinkedHashMap.Builder<K,V> maximumWeightedCapacity(long capacity)
Specifies the maximum weighted capacity to coerce the map to and may exceed it temporarily.- Parameters:
capacity
- the weighted threshold to bound the map by- Throws:
IllegalArgumentException
- if the maximumWeightedCapacity is negative
-
concurrencyLevel
public ConcurrentLinkedHashMap.Builder<K,V> concurrencyLevel(int concurrencyLevel)
Specifies the estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads (default16
).- Parameters:
concurrencyLevel
- the estimated number of concurrently updating threads- Throws:
IllegalArgumentException
- if the concurrencyLevel is less than or equal to zero
-
listener
public ConcurrentLinkedHashMap.Builder<K,V> listener(EvictionListener<K,V> listener)
Specifies an optional listener that is registered for notification when an entry is evicted.- Parameters:
listener
- the object to forward evicted entries to- Throws:
NullPointerException
- if the listener is null
-
build
public ConcurrentLinkedHashMap<K,V> build()
Creates a newConcurrentLinkedHashMap
instance.- Throws:
IllegalStateException
- if the maximum weighted capacity was not set
-
-