Package: org.apache.groovy.util

## [Java] Class ObjectHolder<T>

- org.apache.groovy.util.ObjectHolder

-     public class ObjectHolder<T>
      extends Object

  Just hold an object

  Type Parameters:
    `T` - the type of object

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ObjectHolder()` Creates an empty holder.
    `ObjectHolder(T object)` Creates a holder with an initial object.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public T` | `getObject()` Returns the currently held object.
    `` | `public T` | `getObject(Supplier<? extends T> def)` Returns the currently held object, initializing it from the supplier when needed.
    `` | `public void` | `setObject(T object)` Replaces the currently held object.

  - ### Inherited Methods Summary

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

- - ### Constructor Detail

    - #### public ObjectHolder()

      Creates an empty holder.

    - #### public ObjectHolder(T object)

      Creates a holder with an initial object.

      Parameters:
        `object` - the initial object

  - ### Method Detail

    - #### public T getObject()

      Returns the currently held object.

      Returns:
        the held object

    - #### public T getObject(Supplier<? extends T> def)

      Returns the currently held object, initializing it from the supplier when needed.

      Parameters:
        `def` - the supplier used when no object has been set
      Returns:
        the held object

    - #### public void setObject(T object)

      Replaces the currently held object.

      Parameters:
        `object` - the object to hold