Package io.deephaven.base.reference
Class WeakReferenceWrapper<T>
java.lang.Object
io.deephaven.base.reference.WeakReferenceWrapper<T>
- All Implemented Interfaces:
SimpleReference<T>
SimpleReference implementation created to interpose a strong/hard reference in place of a weak reference, with reachability subject to the continued reachability of the wrapped referent via the wrapped reference.
In general, this only makes sense for concrete subclasses that are simultaneously T's and SimpleReferences to T's. The intended use case is for callback/listener registration chains that maintain reachability for all but the final link in the chain. Classes that wish to enable this functionality must construct their listener references with maybeCreateWeakReference in order to avoid rendering a WeakReferenceWrapper weakly reachable and thereby breaking the chain.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
clear()
Clear the referent.final T
get()
Retrieve the current referent.protected final T
static <T> SimpleReference<T>
maybeCreateWeakReference
(T referent)
-
Constructor Details
-
WeakReferenceWrapper
-
-
Method Details
-
get
Description copied from interface:SimpleReference
Retrieve the current referent.- Specified by:
get
in interfaceSimpleReference<T>
- Returns:
- The current referent, which may be null.
-
clear
public final void clear()Description copied from interface:SimpleReference
Clear the referent.- Specified by:
clear
in interfaceSimpleReference<T>
-
getWrapped
-
maybeCreateWeakReference
-