Package: grails.async

## [Groovy] Class PromiseMap<K, V>

- grails.async.PromiseMap

- All Implemented Interfaces and Traits:
    Promise

      @groovy.transform.CompileStatic
      class PromiseMap
      extends java.lang.Object

  A map-like structure for promises that allows waiting for all values in the map to be populated before executing a callback

  Authors:
    Graeme Rocher
  Since:
    2.3

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected java.util.LinkedHashMap<K, Promise>` | `promises` |
    `protected java.util.LinkedHashMap<Promise, K>` | `promisesKeys` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `PromiseMap ()`
    `PromiseMap (java.util.Map<K, V> values)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `Promise<java.util.Map<K, V>>` | `accept(java.util.Map<K, V> values)`
    `` | `boolean` | `cancel(boolean mayInterruptIfRunning)`
    `` | `boolean` | `containsKey(K o)` @param o The key
    `` | `Promise` | `get(K o)` Gets a promise instance for the given key
    `` | `java.util.Map<K, V>` | `get()` Synchronously return the populated map with all values obtained from promises used inside the populated map
    `` | `java.util.Map<K, V>` | `get(long timeout, java.util.concurrent.TimeUnit units)` Synchronously return the populated map with all values obtained from promises used inside the populated map
    `` | `Promise` | `getAt(K o)` Gets a promise instance for the given key
    `` | `boolean` | `isCancelled()`
    `` | `boolean` | `isDone()`
    `` | `boolean` | `isEmpty()` @return Whether the map is empty
    `` | `Promise<java.util.Map<K, V>>` | `leftShift(groovy.lang.Closure callable)`
    `` | `Promise<java.util.Map<K, V>>` | `onComplete(groovy.lang.Closure callable)`
    `` | `Promise<java.util.Map<K, V>>` | `onError(groovy.lang.Closure callable)`
    `` | `Promise` | `put(K k, java.lang.Object value)` Put any value and return a promise for that value
    `` | `Promise` | `put(K k, Promise promise)` Adds a promise for the given key
    `` | `Promise` | `put(K k, groovy.lang.Closure callable)` Adds a promise for the given key
    `` | `Promise` | `putAt(java.lang.String k, Promise promise)` Adds a promise for the given key
    `` | `Promise` | `putAt(java.lang.String k, groovy.lang.Closure promise)` Adds a promise for the given key
    `` | `Promise` | `putAt(java.lang.String k, java.lang.Object value)` Adds a promise for the given key
    `` | `Promise` | `putAt(java.lang.Integer k, Promise promise)` Adds a promise for the given key
    `` | `Promise` | `putAt(java.lang.Integer k, groovy.lang.Closure promise)` Adds a promise for the given key
    `` | `int` | `size()` @return The size the map
    `` | `Promise<java.util.Map<K, V>>` | `then(groovy.lang.Closure callable)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### protected java.util.LinkedHashMap<K, Promise> promises

    - #### protected java.util.LinkedHashMap<Promise, K> promisesKeys

  - ### Constructor Detail

    - #### PromiseMap()

    - #### PromiseMap(java.util.Map<K, V> values)

  - ### Method Detail

    - #### @java.lang.Override Promise<java.util.Map<K, V>> accept(java.util.Map<K, V> values)

    - #### @java.lang.Override boolean cancel(boolean mayInterruptIfRunning)

    - #### boolean containsKey(K o)

      Parameters:
        `o` - The key
      Returns:
        Whether the promise map contains the given key

    - #### Promise get(K o)

      Gets a promise instance for the given key

      Parameters:
        `o` - The key
      Returns:
        A promise

    - #### java.util.Map<K, V> get()

      Synchronously return the populated map with all values obtained from promises used inside the populated map

      Returns:
        A map where the values are obtained from the promises

    - #### java.util.Map<K, V> get(long timeout, java.util.concurrent.TimeUnit units)

      Synchronously return the populated map with all values obtained from promises used inside the populated map

      Parameters:
        `timeout` - The timeout period
        `units` - The timeout units
      Returns:
        A map where the values are obtained from the promises

    - #### Promise getAt(K o)

      Gets a promise instance for the given key

      Parameters:
        `o` - The key
      Returns:
        A promise

    - #### @java.lang.Override boolean isCancelled()

    - #### @java.lang.Override boolean isDone()

    - #### boolean isEmpty()

      Returns:
        Whether the map is empty

    - #### Promise<java.util.Map<K, V>> leftShift(groovy.lang.Closure callable)

    - #### Promise<java.util.Map<K, V>> onComplete(groovy.lang.Closure callable)

    - #### Promise<java.util.Map<K, V>> onError(groovy.lang.Closure callable)

    - #### Promise put(K k, java.lang.Object value)

      Put any value and return a promise for that value

      Parameters:
        `k` - The key
        `value` - The value
      Returns:
        The promise

    - #### Promise put(K k, Promise promise)

      Adds a promise for the given key

      Parameters:
        `k` - The key
        `promise` - The promise
      Returns:
        The previous promise

    - #### Promise put(K k, groovy.lang.Closure callable)

      Adds a promise for the given key

      Parameters:
        `k` - The key
        `promise` - The promise
      Returns:
        The previous promise

    - #### Promise putAt(java.lang.String k, Promise promise)

      Adds a promise for the given key

      Parameters:
        `k` - The key
        `promise` - The promise
      Returns:
        The previous promise

    - #### Promise putAt(java.lang.String k, groovy.lang.Closure promise)

      Adds a promise for the given key

      Parameters:
        `k` - The key
        `promise` - The promise
      Returns:
        The previous promise

    - #### Promise putAt(java.lang.String k, java.lang.Object value)

      Adds a promise for the given key

      Parameters:
        `k` - The key
        `promise` - The promise
      Returns:
        The previous promise

    - #### Promise putAt(java.lang.Integer k, Promise promise)

      Adds a promise for the given key

      Parameters:
        `k` - The key
        `promise` - The promise
      Returns:
        The previous promise

    - #### Promise putAt(java.lang.Integer k, groovy.lang.Closure promise)

      Adds a promise for the given key

      Parameters:
        `k` - The key
        `promise` - The promise
      Returns:
        The previous promise

    - #### int size()

      Returns:
        The size the map

    - #### Promise<java.util.Map<K, V>> then(groovy.lang.Closure callable)