# 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

  Constructors
  Constructor
  Description
  `Builder()`
  Constructs a new instances of `ConcurrentReferenceHashMap`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ConcurrentReferenceHashMap<K,V>`
  `get()`
  Builds a new `ConcurrentReferenceHashMap`.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `setConcurrencyLevel(int concurrencyLevel)`
  Sets the estimated number of concurrently updating threads.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `setInitialCapacity(int initialCapacity)`
  Sets the initial capacity.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `setKeyReferenceType(ConcurrentReferenceHashMap.ReferenceType keyReferenceType)`
  Sets the reference type to use for keys.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `setLoadFactor(float loadFactor)`
  Sets the load factor factor, used to control resizing.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `setOptions(EnumSet<ConcurrentReferenceHashMap.Option> options)`
  Sets the behavioral options.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `setSourceMap(Map<? extends K,? extends V> sourceMap)`
  Sets the values to load into a new map.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `setValueReferenceType(ConcurrentReferenceHashMap.ReferenceType valueReferenceType)`
  Sets the reference type to use for values.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `softKeys()`
  Sets key reference type to `ConcurrentReferenceHashMap.ReferenceType.SOFT`.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `softValues()`
  Sets value reference type to `ConcurrentReferenceHashMap.ReferenceType.SOFT`.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `strongKeys()`
  Sets key reference type to `ConcurrentReferenceHashMap.ReferenceType.STRONG`.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `strongValues()`
  Sets value reference type to `ConcurrentReferenceHashMap.ReferenceType.STRONG`.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `weakKeys()`
  Sets key reference type to `ConcurrentReferenceHashMap.ReferenceType.WEAK`.
  `ConcurrentReferenceHashMap.Builder<K,V>`
  `weakValues()`
  Sets value reference type to `ConcurrentReferenceHashMap.ReferenceType.WEAK`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Builder

    public Builder()
    Constructs a new instances of `ConcurrentReferenceHashMap`.

- ## Method Details

  - ### get

    public ConcurrentReferenceHashMap<K,V> get()
    Builds a new `ConcurrentReferenceHashMap`.

    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:
      `get` in interface `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(EnumSet<ConcurrentReferenceHashMap.Option> options)
    Sets the behavioral options.
    Parameters:
      `options` - the behavioral options.
    Returns:
      this instance.

  - ### setSourceMap

    public ConcurrentReferenceHashMap.Builder<K,V> setSourceMap(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 to `ConcurrentReferenceHashMap.ReferenceType.SOFT`.
    Returns:
      this instance.

  - ### softValues

    public ConcurrentReferenceHashMap.Builder<K,V> softValues()
    Sets value reference type to `ConcurrentReferenceHashMap.ReferenceType.SOFT`.
    Returns:
      this instance.

  - ### strongKeys

    public ConcurrentReferenceHashMap.Builder<K,V> strongKeys()
    Sets key reference type to `ConcurrentReferenceHashMap.ReferenceType.STRONG`.
    Returns:
      this instance.

  - ### strongValues

    public ConcurrentReferenceHashMap.Builder<K,V> strongValues()
    Sets value reference type to `ConcurrentReferenceHashMap.ReferenceType.STRONG`.
    Returns:
      this instance.

  - ### weakKeys

    public ConcurrentReferenceHashMap.Builder<K,V> weakKeys()
    Sets key reference type to `ConcurrentReferenceHashMap.ReferenceType.WEAK`.
    Returns:
      this instance.

  - ### weakValues

    public ConcurrentReferenceHashMap.Builder<K,V> weakValues()
    Sets value reference type to `ConcurrentReferenceHashMap.ReferenceType.WEAK`.
    Returns:
      this instance.