com.holonplatform.core

## Interface Initializer<T>

- Type Parameters:
    `T` - Type of the value to lazy initialize
  Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

      @FunctionalInterface
      public interface Initializer<T>

  Interface for lazy initialization of a generic value.
  Since:
    5.0.0

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `get()` Gets the value, initializing it if the value is not already initialized before returning to caller.
    `static <T> T` | `init(T value, Supplier<T> initializer)` Lazy initializing method using given `initializer` to initialize the value if given `value` is `null`.
    `static <T> Initializer<T>` | `using(Supplier<T> initializer)` Create a new `Initializer` using given `initializer` `Supplier` for value initialization.

- - ### Method Detail

    - #### get

          T get()

      Gets the value, initializing it if the value is not already initialized before returning to caller.
      Returns:
        the (lazy initialized) value

    - #### using

          static <T> Initializer<T> using(Supplier<T> initializer)

      Create a new `Initializer` using given `initializer` `Supplier` for value initialization.

      The returned `Initializer` is thread-safe, ensuring that the initializer `Supplier` is called exactly one time following one or several calls of `get()` by any number of threads.

      Type Parameters:
        `T` - Type of the value to lazy initialize
      Parameters:
        `initializer` - Supplier to initialize the value. Must never return `null`.
      Returns:
        A new `Initializer` instance

    - #### init

          static <T> T init(T value,
                            Supplier<T> initializer)

      Lazy initializing method using given `initializer` to initialize the value if given `value` is `null`.
      Type Parameters:
        `T` - Type of the value to lazy initialize
      Parameters:
        `value` - Value to return if not `null`
        `initializer` - Supplier to initialize the value. Must never return `null`.
      Returns:
        The given `value` if not `null`, or the initialized value using `Supplier.get()` method of given `initializer`

Copyright © 2017 The Holon Platform. All rights reserved.