Package: org.codehaus.groovy.util

## [Java] Class LazyReference<T>

- org.codehaus.groovy.util.LazyReference

-     public abstract class LazyReference<T>
      extends LockableObject

  Soft reference with lazy initialization under lock

- - ### Constructor Summary

    Constructors
    Constructor and description
    `LazyReference(ReferenceBundle bundle)` Creates a lazily initialized reference that stores computed values using the supplied bundle.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `clear()` Discards the cached state so the next get() call recomputes it.
    `` | `public T` | `get()` Returns the current value, initializing or recreating it when necessary.
    `` | `public abstract T` | `initValue()` Computes the value to cache for future get() calls.
    `` | `public String` | `toString()` Returns the current cached value as a string, or `<null>` when no value is available.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class LockableObject` | `isHeldExclusively, lock, tryAcquire, tryRelease, unlock`

- - ### Constructor Detail

    - #### public LazyReference(ReferenceBundle bundle)

      Creates a lazily initialized reference that stores computed values using the supplied bundle.

      Parameters:
        `bundle` - the reference strategy to use after initialization

  - ### Method Detail

    - #### public void clear()

      Discards the cached state so the next get() call recomputes it.

    - #### public T get()

      Returns the current value, initializing or recreating it when necessary.

      Returns:
        the current value, which may be `null`

    - #### public abstract T initValue()

      Computes the value to cache for future get() calls.

      Returns:
        the value to cache, or `null` to cache a null result

    - #### public String toString()

      Returns the current cached value as a string, or `<null>` when no value is available.

      Returns:
        a string form of the cached value