Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.common.base
Class Suppliers

    java.lang.Object
      com.google.common.base.Suppliers

    public final class Suppliers

extends Object

Useful suppliers.

All methods return serializable suppliers as long as they're given serializable parameters.

Author:
  Laurence Gonsalves, Harry Heymann

Method Summary
`static
`<F,T> Supplier<T>`
` | `compose(Function<? super F,T> function, Supplier<F> first)` Returns a new supplier which is the composition of the provided function and supplier.
`static
`<T> Supplier<T>`
` | `memoize(Supplier<T> delegate)` Returns a supplier which caches the instance retrieved during the first call to `get()` and returns that value on subsequent calls to `get()`.
`static
`<T> Supplier<T>`
` | `ofInstance(T instance)` Returns a supplier that always supplies `instance`.
`static
`<T> Supplier<T>`
` | `synchronizedSupplier(Supplier<T> delegate)` Returns a supplier whose `get()` method synchronizes on `delegate` before calling it, making it thread-safe.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### compose

    public static <F,T> Supplier<T> compose(Function<? super F,T> function,
                                            Supplier<F> first)

  Returns a new supplier which is the composition of the provided function and supplier. In other words, the new supplier's value will be computed by retrieving the value from `first`, and then applying `function` to that value. Note that the resulting supplier will not call `first` or invoke `function` until it is called.

### memoize

    public static <T> Supplier<T> memoize(Supplier<T> delegate)

  Returns a supplier which caches the instance retrieved during the first call to `get()` and returns that value on subsequent calls to `get()`. See: memoization

  The returned supplier is thread-safe. The supplier's serialized form does not contain the cached value, which will be recalculated when `get()` is called on the reserialized instance.

### ofInstance

    public static <T> Supplier<T> ofInstance(@Nullable
                                             T instance)

  Returns a supplier that always supplies `instance`.

### synchronizedSupplier

    public static <T> Supplier<T> synchronizedSupplier(Supplier<T> delegate)

  Returns a supplier whose `get()` method synchronizes on `delegate` before calling it, making it thread-safe.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD