Class ObjectHolder<T>

java.lang.Object
org.apache.groovy.util.ObjectHolder<T>
Type Parameters:
T - the type of object

public class ObjectHolder<T> extends Object
Just hold an object
  • Constructor Details

    • ObjectHolder

      public ObjectHolder()
      Creates an empty holder.
    • ObjectHolder

      public ObjectHolder(T object)
      Creates a holder with an initial object.
      Parameters:
      object - the initial object
  • Method Details

    • getObject

      public T getObject()
      Returns the currently held object.
      Returns:
      the held object
    • getObject

      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
    • setObject

      public void setObject(T object)
      Replaces the currently held object.
      Parameters:
      object - the object to hold