Package tripleplay.ui.util
Class Supplier
java.lang.Object
tripleplay.ui.util.Supplier
- All Implemented Interfaces:
AutoCloseable
,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
-
Method Summary
Modifier and TypeMethodDescriptionstatic Supplier
Creates a supplier that will return a previously created element the first time and null thereafter.void
close()
Disposes resources associated with the supplier instance.abstract Element<?>
get()
Gets the element.static Supplier
withDispose
(Supplier other) Creates a supplier that wraps another supplier and on dispose also disposes the created element, if it implementsCloseable
.
-
Constructor Details
-
Supplier
public Supplier()
-
-
Method Details
-
auto
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
Creates a supplier that wraps another supplier and on dispose also disposes the created element, if it implementsCloseable
. -
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 itslayer.close
later. -
close
public void close()Disposes resources associated with the supplier instance. The base class implementation does nothing.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfacereact.Closeable
-