ConcurrentLinkedHashMap.Builder (groovy 3.0.9 API)

Package: org.apache.groovy.util.concurrent.concurrentlinkedhashmap

## [Java] Class ConcurrentLinkedHashMap.Builder<K, V>

- org.apache.groovy.util.concurrent.concurrentlinkedhashmap.ConcurrentLinkedHashMap.Builder

-     public static final class ConcurrentLinkedHashMap.Builder<K, V>

  A builder that creates ConcurrentLinkedHashMap 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)
           .weigher(Weighers.<Edge>set())
           .build();

- - ### Constructor Summary

    Constructors
    Constructor and description
    `Builder ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public ConcurrentLinkedHashMap<K, V>` | `build()` Creates a new ConcurrentLinkedHashMap instance.
    `` | `public Builder<K, V>` | `concurrencyLevel(int concurrencyLevel)` Specifies the estimated number of concurrently updating threads.
    `` | `public Builder<K, V>` | `initialCapacity(int initialCapacity)` Specifies the initial capacity of the hash table (default `16`).
    `` | `public Builder<K, V>` | `listener(EvictionListener<K, V> listener)` Specifies an optional listener that is registered for notification when an entry is evicted.
    `` | `public Builder<K, V>` | `maximumWeightedCapacity(long capacity)` Specifies the maximum weighted capacity to coerce the map to and may exceed it temporarily.
    `` | `public Builder<K, V>` | `weigher(Weigher<? super V> weigher)` Specifies an algorithm to determine how many the units of capacity a value consumes.
    `` | `public Builder<K, V>` | `weigher(EntryWeigher<? super K, ? super V> weigher)` Specifies an algorithm to determine how many the units of capacity an entry consumes.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Constructor Detail

    - #### @SuppressWarnings("unchecked") public Builder()

  - ### Method Detail

    - #### public ConcurrentLinkedHashMap<K, V> build()

      Creates a new ConcurrentLinkedHashMap instance.

      throws:
        IllegalStateException if the maximum weighted capacity was not set

    - #### public 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 (default `16`).

      throws:
        IllegalArgumentException if the concurrencyLevel is less than or equal to zero
      Parameters:
        `concurrencyLevel` - the estimated number of concurrently updating threads

    - #### public Builder<K, V> initialCapacity(int initialCapacity)

      Specifies the initial capacity of the hash table (default `16`). This is the number of key-value pairs that the hash table can hold before a resize operation is required.

      throws:
        IllegalArgumentException if the initialCapacity is negative
      Parameters:
        `initialCapacity` - the initial capacity used to size the hash table to accommodate this many entries.

    - #### public Builder<K, V> listener(EvictionListener<K, V> listener)

      Specifies an optional listener that is registered for notification when an entry is evicted.

      throws:
        NullPointerException if the listener is null
      Parameters:
        `listener` - the object to forward evicted entries to

    - #### public Builder<K, V> maximumWeightedCapacity(long capacity)

      Specifies the maximum weighted capacity to coerce the map to and may exceed it temporarily.

      throws:
        IllegalArgumentException if the maximumWeightedCapacity is negative
      Parameters:
        `capacity` - the weighted threshold to bound the map by

    - #### public Builder<K, V> weigher(Weigher<? super V> weigher)

      Specifies an algorithm to determine how many the units of capacity a value consumes. The default algorithm bounds the map by the number of key-value pairs by giving each entry a weight of `1`.

      throws:
        NullPointerException if the weigher is null
      Parameters:
        `weigher` - the algorithm to determine a value's weight

    - #### public Builder<K, V> weigher(EntryWeigher<? super K, ? super V> weigher)

      Specifies an algorithm to determine how many the units of capacity an entry consumes. The default algorithm bounds the map by the number of key-value pairs by giving each entry a weight of `1`.

      throws:
        NullPointerException if the weigher is null
      Parameters:
        `weigher` - the algorithm to determine a entry's weight