Package io.axoniq.dataprotection.serialization

## Class CachingSupplier<T>

- java.lang.Object
- - io.axoniq.dataprotection.serialization.CachingSupplier<T>

- All Implemented Interfaces:
    `Serializable`, `Supplier<T>`

      public class CachingSupplier<T>
      extends Object
      implements Supplier<T>, Serializable

  A Supplier that caches its result, useful if the supplier operation is expensive and expected to always yield the same result. This supplier can be used concurrently by multiple threads.
  Author:
    Rene de Waele
  See Also:
    Serialized Form

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `T` | `get()` |
    `static <T> CachingSupplier<T>` | `of​(Supplier<T> supplier)` | Factory method for a `CachingSupplier` that delegates to the given `supplier` when asked to supply a value.
    `static <T> CachingSupplier<T>` | `of​(T value)` | Factory method for a `CachingSupplier` that will supply the given `value`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### of

          public static <T> CachingSupplier<T> of​(T value)

      Factory method for a `CachingSupplier` that will supply the given `value`. This factory method should be used when the value is already available. Used this way this supplier can be serialized.
      Type Parameters:
        `T` - the type of results supplied by this supplier
      Parameters:
        `value` - the value to supply
      Returns:
        a `CachingSupplier` that supplies the given value

    - #### of

          public static <T> CachingSupplier<T> of​(Supplier<T> supplier)

      Factory method for a `CachingSupplier` that delegates to the given `supplier` when asked to supply a value. If the given `supplier` is a `CachingSupplier` the instance is returned as is, if not a new `CachingSupplier` instance is created.
      Type Parameters:
        `T` - the type of results supplied by this supplier
      Parameters:
        `supplier` - supplier for which to cache the result
      Returns:
        a `CachingSupplier` based on given `supplier`

    - #### get

          public T get()

      Specified by:
        `get` in interface `Supplier<T>`