Package tripleplay.util
Class Ref<T>
java.lang.Object
tripleplay.util.Ref<T>
Maintains a reference to a resource. Handles destroying the resource before releasing the
reference.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the target of this reference.static <T extends react.Closeable>
Ref<T>create
(T target) Creates a reference to aCloseable
target.get()
Returns the current value of this reference, which may be null.Sets the current value of this reference, clearing any previously referenced object.
-
Constructor Details
-
Ref
public Ref()
-
-
Method Details
-
create
Creates a reference to aCloseable
target. -
get
Returns the current value of this reference, which may be null. -
set
Sets the current value of this reference, clearing any previously referenced object.- Returns:
target
to enabled code like:F foo = fooref.set(new F())
.
-
clear
public void clear()Clears the target of this reference. Automatically callsonClear(T)
if the reference contains a non-null target.
-