Package: org.apache.groovy.runtime.async

## [Java] Class ScopedLocal.Carrier

- org.apache.groovy.runtime.async.ScopedLocal.Carrier

-     public static final class ScopedLocal.Carrier
      extends Object

  An immutable set of scoped-local bindings that can be applied atomically for the duration of a Runnable or Supplier.

  Since:
    6.0.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `<R>` | `public R` | `call(Supplier<R> supplier)` Executes the supplier with all bindings in this carrier active and returns its result.
    `` | `public void` | `run(Runnable action)` Executes the action with all bindings in this carrier active.
    `<T>` | `public ScopedLocal.Carrier` | `where(ScopedLocal<T> key, T value)` Adds another binding to this carrier, returning a new carrier that includes all previous bindings plus the new one.

  - ### Inherited Methods Summary

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

- - ### Method Detail

    - #### <R> public R call(Supplier<R> supplier)

      Executes the supplier with all bindings in this carrier active and returns its result.

      Type Parameters:
        `R` - the result type
      Parameters:
        `supplier` - the supplier to execute
      Returns:
        the supplier's result

    - #### public void run(Runnable action)

      Executes the action with all bindings in this carrier active.

      Parameters:
        `action` - the action to execute

    - #### <T> public ScopedLocal.Carrier where(ScopedLocal<T> key, T value)

      Adds another binding to this carrier, returning a new carrier that includes all previous bindings plus the new one.

      Type Parameters:
        `T` - the value type
      Parameters:
        `key` - the scoped-local to bind
        `value` - the value to bind; may be `null`
      Returns:
        a new carrier with the additional binding