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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclear()Clear the referent.final Tget()Retrieve the current referent.protected final Tstatic <T> SimpleReference<T>maybeCreateWeakReference(T referent)
-
Constructor Details
-
WeakReferenceWrapper
-
-
Method Details
-
get
Description copied from interface:SimpleReferenceRetrieve the current referent.- Specified by:
getin interfaceSimpleReference<T>- Returns:
- The current referent, which may be null.
-
clear
public final void clear()Description copied from interface:SimpleReferenceClear the referent.- Specified by:
clearin interfaceSimpleReference<T>
-
getWrapped
-
maybeCreateWeakReference
-