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:
java.util.function.Supplier<ConcurrentReferenceHashMap<K,V>>
- Enclosing class:
- ConcurrentReferenceHashMap<K,V>
public static class ConcurrentReferenceHashMap.Builder<K,V> extends java.lang.Object implements java.util.function.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
Constructors Constructor Description Builder()Constructs a new instances ofConcurrentReferenceHashMap.
-
Method Summary
-
-
-
Constructor Detail
-
Builder
public Builder()
Constructs a new instances ofConcurrentReferenceHashMap.
-
-
Method Detail
-
get
public ConcurrentReferenceHashMap<K,V> 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
- Specified by:
getin interfacejava.util.function.Supplier<K>
-
setConcurrencyLevel
public ConcurrentReferenceHashMap.Builder<K,V> setConcurrencyLevel(int concurrencyLevel)
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
public ConcurrentReferenceHashMap.Builder<K,V> setInitialCapacity(int initialCapacity)
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
public ConcurrentReferenceHashMap.Builder<K,V> setLoadFactor(float loadFactor)
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(java.util.EnumSet<ConcurrentReferenceHashMap.Option> options)
Sets the behavioral options.- Parameters:
options- the behavioral options.- Returns:
- this instance.
-
setSourceMap
public ConcurrentReferenceHashMap.Builder<K,V> setSourceMap(java.util.Map<? extends K,? extends V> sourceMap)
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
public ConcurrentReferenceHashMap.Builder<K,V> softKeys()
Sets key reference type toConcurrentReferenceHashMap.ReferenceType.SOFT.- Returns:
- this instance.
-
softValues
public ConcurrentReferenceHashMap.Builder<K,V> softValues()
Sets value reference type toConcurrentReferenceHashMap.ReferenceType.SOFT.- Returns:
- this instance.
-
strongKeys
public ConcurrentReferenceHashMap.Builder<K,V> strongKeys()
Sets key reference type toConcurrentReferenceHashMap.ReferenceType.STRONG.- Returns:
- this instance.
-
strongValues
public ConcurrentReferenceHashMap.Builder<K,V> strongValues()
Sets value reference type toConcurrentReferenceHashMap.ReferenceType.STRONG.- Returns:
- this instance.
-
weakKeys
public ConcurrentReferenceHashMap.Builder<K,V> weakKeys()
Sets key reference type toConcurrentReferenceHashMap.ReferenceType.WEAK.- Returns:
- this instance.
-
weakValues
public ConcurrentReferenceHashMap.Builder<K,V> weakValues()
Sets value reference type toConcurrentReferenceHashMap.ReferenceType.WEAK.- Returns:
- this instance.
-
-