Class ConcurrentReferenceHashMap.Builder<K,V>
java.lang.Object
org.apache.commons.collections4.map.ConcurrentReferenceHashMap.Builder<K,V>
- Type Parameters:
K
- the type of keys.V
- the type of values.
- All Implemented Interfaces:
Supplier<ConcurrentReferenceHashMap<K,
V>>
- Enclosing class:
ConcurrentReferenceHashMap<K,
V>
public static class ConcurrentReferenceHashMap.Builder<K,V>
extends Object
implements Supplier<ConcurrentReferenceHashMap<K,V>>
Builds new ConcurrentReferenceHashMap instances.
By default, keys are weak, and values are strong.
The default values are:
- concurrency level: 16
- initial capacity: 16
- key reference type:
ConcurrentReferenceHashMap.ReferenceType.WEAK
- load factor: 0.75f
- options:
null
- source map:
null
- value reference type:
ConcurrentReferenceHashMap.ReferenceType.STRONG
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionget()
Builds a newConcurrentReferenceHashMap
.setConcurrencyLevel
(int concurrencyLevel) Sets the estimated number of concurrently updating threads.setInitialCapacity
(int initialCapacity) Sets the initial capacity.setKeyReferenceType
(ConcurrentReferenceHashMap.ReferenceType keyReferenceType) Sets the reference type to use for keys.setLoadFactor
(float loadFactor) Sets the load factor factor, used to control resizing.Sets the behavioral options.setSourceMap
(Map<? extends K, ? extends V> sourceMap) Sets the values to load into a new map.setValueReferenceType
(ConcurrentReferenceHashMap.ReferenceType valueReferenceType) Sets the reference type to use for values.softKeys()
Sets key reference type toConcurrentReferenceHashMap.ReferenceType.SOFT
.Sets value reference type toConcurrentReferenceHashMap.ReferenceType.SOFT
.Sets key reference type toConcurrentReferenceHashMap.ReferenceType.STRONG
.Sets value reference type toConcurrentReferenceHashMap.ReferenceType.STRONG
.weakKeys()
Sets key reference type toConcurrentReferenceHashMap.ReferenceType.WEAK
.Sets value reference type toConcurrentReferenceHashMap.ReferenceType.WEAK
.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
get
Builds a newConcurrentReferenceHashMap
.By default, keys are weak, and values are strong.
The default values are:
- concurrency level: 16
- initial capacity: 16
- key reference type:
ConcurrentReferenceHashMap.ReferenceType.WEAK
- load factor: 0.75f
- options:
null
- source map:
null
- value reference type:
ConcurrentReferenceHashMap.ReferenceType.STRONG
-
setConcurrencyLevel
Sets the estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads.- Parameters:
concurrencyLevel
- estimated number of concurrently updating threads- Returns:
- this instance.
-
setInitialCapacity
Sets the initial capacity. The implementation performs internal sizing to accommodate this many elements.- Parameters:
initialCapacity
- the initial capacity.- Returns:
- this instance.
-
setKeyReferenceType
public ConcurrentReferenceHashMap.Builder<K,V> setKeyReferenceType(ConcurrentReferenceHashMap.ReferenceType keyReferenceType) Sets the reference type to use for keys.- Parameters:
keyReferenceType
- the reference type to use for keys.- Returns:
- this instance.
-
setLoadFactor
Sets the load factor factor, used to control resizing. Resizing may be performed when the average number of elements per bin exceeds this threshold.- Parameters:
loadFactor
- the load factor factor, used to control resizing- Returns:
- this instance.
-
setOptions
public ConcurrentReferenceHashMap.Builder<K,V> setOptions(EnumSet<ConcurrentReferenceHashMap.Option> options) Sets the behavioral options.- Parameters:
options
- the behavioral options.- Returns:
- this instance.
-
setSourceMap
Sets the values to load into a new map.- Parameters:
sourceMap
- the values to load into a new map.- Returns:
- this instance.
-
setValueReferenceType
public ConcurrentReferenceHashMap.Builder<K,V> setValueReferenceType(ConcurrentReferenceHashMap.ReferenceType valueReferenceType) Sets the reference type to use for values.- Parameters:
valueReferenceType
- the reference type to use for values.- Returns:
- this instance.
-
softKeys
Sets key reference type toConcurrentReferenceHashMap.ReferenceType.SOFT
.- Returns:
- this instance.
-
softValues
Sets value reference type toConcurrentReferenceHashMap.ReferenceType.SOFT
.- Returns:
- this instance.
-
strongKeys
Sets key reference type toConcurrentReferenceHashMap.ReferenceType.STRONG
.- Returns:
- this instance.
-
strongValues
Sets value reference type toConcurrentReferenceHashMap.ReferenceType.STRONG
.- Returns:
- this instance.
-
weakKeys
Sets key reference type toConcurrentReferenceHashMap.ReferenceType.WEAK
.- Returns:
- this instance.
-
weakValues
Sets value reference type toConcurrentReferenceHashMap.ReferenceType.WEAK
.- Returns:
- this instance.
-