Class Supplier

java.lang.Object
tripleplay.ui.util.Supplier
All Implemented Interfaces:
AutoCloseable, react.Closeable

public abstract class Supplier extends Object implements react.Closeable
Supplies elements. The means of achieving this depends on the situation. Common cases are to provide a fixed instance or to construct a new element for the caller to cache. Particular attention is paid to ownership and orderly resource disposal.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface react.Closeable

    react.Closeable.Set, react.Closeable.Util
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Supplier
    auto(Element<?> elem)
    Creates a supplier that will return a previously created element the first time and null thereafter.
    void
    Disposes resources associated with the supplier instance.
    abstract Element<?>
    get()
    Gets the element.
    static Supplier
    Creates a supplier that wraps another supplier and on dispose also disposes the created element, if it implements Closeable.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Supplier

      public Supplier()
  • Method Details

    • auto

      public static Supplier auto(Element<?> elem)
      Creates a supplier that will return a previously created element the first time and null thereafter. If the element is still present when dispose is called, the element's layer will be disposeed.
    • withDispose

      public static Supplier withDispose(Supplier other)
      Creates a supplier that wraps another supplier and on dispose also disposes the created element, if it implements Closeable.
    • get

      public abstract Element<?> get()
      Gets the element. Ownership of the element's resources (its layer) must also be transferred. For example, if you don't add the element to any hierarchy, you need to call its layer.close later.
    • close

      public void close()
      Disposes resources associated with the supplier instance. The base class implementation does nothing.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface react.Closeable