Package io.smallrye.common.ref
Class WeakReference<T,A>
- java.lang.Object
-
- java.lang.ref.Reference<T>
-
- java.lang.ref.WeakReference<T>
-
- io.smallrye.common.ref.WeakReference<T,A>
-
- Type Parameters:
T- the reference value typeA- the attachment type
- All Implemented Interfaces:
Reference<T,A>
public class WeakReference<T,A> extends WeakReference<T> implements Reference<T,A>
A reapable weak reference with an attachment. If aReaperis given, then it will be used to asynchronously clean up the referent.- See Also:
WeakReference
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.smallrye.common.ref.Reference
Reference.Type
-
-
Constructor Summary
Constructors Constructor Description WeakReference(T referent)Construct a new instance.WeakReference(T referent, A attachment)Construct a new instance.WeakReference(T referent, A attachment, Reaper<T,A> reaper)Construct a new instance with a reaper.WeakReference(T referent, A attachment, ReferenceQueue<? super T> q)Construct a new instance with an explicit reference queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AgetAttachment()Get the attachment, if any.Reaper<T,A>getReaper()Reference.TypegetType()Get the type of the reference.StringtoString()-
Methods inherited from class java.lang.ref.Reference
clear, clone, enqueue, get, isEnqueued, reachabilityFence
-
-
-
-
Constructor Detail
-
WeakReference
public WeakReference(T referent)
Construct a new instance.- Parameters:
referent- the referent
-
WeakReference
public WeakReference(T referent, A attachment)
Construct a new instance.- Parameters:
referent- the referentattachment- the attachment
-
WeakReference
public WeakReference(T referent, A attachment, ReferenceQueue<? super T> q)
Construct a new instance with an explicit reference queue.- Parameters:
referent- the referentattachment- the attachmentq- the reference queue to use
-
-
Method Detail
-
getAttachment
public A getAttachment()
Description copied from interface:ReferenceGet the attachment, if any.- Specified by:
getAttachmentin interfaceReference<T,A>- Returns:
- the attachment
-
getType
public Reference.Type getType()
Description copied from interface:ReferenceGet the type of the reference.
-
-