PromiseMap (Grails 2.3.8)
Date: 2014-04-24

Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## grails.async
[Groovy] Class PromiseMap

    java.lang.Object
      grails.async.PromiseMap

All Implemented Interfaces:
  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
`protected java.util.LinkedHashMap` | `promises`
`protected java.util.LinkedHashMap` | `promisesKeys`

Constructor Summary
`PromiseMap()`
`PromiseMap(java.util.Map values)`

Method Summary
`boolean` | `containsKey(java.lang.Object o)` @param o The key
`Promise` | `get(java.lang.Object o)` Gets a promise instance for the given key
`java.util.Map` | `get()` Synchronously return the populated map with all values obtained from promises used inside the populated map
`java.util.Map` | `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(java.lang.Object o)` Gets a promise instance for the given key
`boolean` | `isEmpty()` @return Whether the map is empty
`Promise` | `leftShift(groovy.lang.Closure callable)`
`Promise` | `onComplete(groovy.lang.Closure callable)`
`Promise` | `onError(groovy.lang.Closure callable)`
`Promise` | `put(java.lang.Object k, java.lang.Object value)` Put any value and return a promise for that value
`Promise` | `put(java.lang.Object k, Promise promise)` Adds a promise for the given key
`Promise` | `put(java.lang.Object 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` | `then(groovy.lang.Closure callable)`

Methods inherited from 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

### promises

    protected java.util.LinkedHashMap promises

### promisesKeys

    protected java.util.LinkedHashMap promisesKeys

Constructor Detail

### PromiseMap

    PromiseMap()

### PromiseMap

    PromiseMap(java.util.Map values)

Method Detail

### containsKey

    boolean containsKey(java.lang.Object o)

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

### get

    Promise get(java.lang.Object o)

  Gets a promise instance for the given key
  Parameters:
    `o` - The key
  Returns:
    A promise

### get

    java.util.Map 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

### get

    java.util.Map 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

### getAt

    Promise getAt(java.lang.Object o)

  Gets a promise instance for the given key
  Parameters:
    `o` - The key
  Returns:
    A promise

### isEmpty

    boolean isEmpty()

  Returns:
    Whether the map is empty

### leftShift

    Promise leftShift(groovy.lang.Closure callable)

### onComplete

    Promise onComplete(groovy.lang.Closure callable)

### onError

    Promise onError(groovy.lang.Closure callable)

### put

    Promise put(java.lang.Object 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

### put

    Promise put(java.lang.Object k, Promise promise)

  Adds a promise for the given key
  Parameters:
    `k` - The key
    `promise` - The promise
  Returns:
    The previous promise

### put

    Promise put(java.lang.Object k, groovy.lang.Closure callable)

  Adds a promise for the given key
  Parameters:
    `k` - The key
    `promise` - The promise
  Returns:
    The previous promise

### putAt

    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

### putAt

    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

### putAt

    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

### putAt

    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

### putAt

    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

### size

    int size()

  Returns:
    The size the map

### then

    Promise then(groovy.lang.Closure callable)

Groovy Documentation