Class EquatableWeakReference<T>
java.lang.Object
java.lang.ref.Reference<T>
java.lang.ref.WeakReference<T>
etithespirit.orimod.util.collection.EquatableWeakReference<T>
- Type Parameters:
T
-
A modified variation of a weak reference that somewhat violates its contract by allowing two things:
- Allowing this reference to be compared to another with
equals(java.lang.Object)
- Allowing this reference to form a strong reference to its stored object (for its use in
WeakList
)
-
Constructor Summary
ConstructorsConstructorDescriptionEquatableWeakReference
(T referent) Creates a new weak reference that refers to the given object.EquatableWeakReference
(T referent, ReferenceQueue<? super T> q) Creates a new weak reference that refers to the given object and is registered with the given queue. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static <T> EquatableWeakReference<T>
from
(WeakReference<T> standard) boolean
isStrong()
void
makeWeak()
Returns this reference to its weak state.boolean
Attempts to make this reference strong.Methods inherited from class java.lang.ref.Reference
clear, clone, enqueue, get, isEnqueued, reachabilityFence, refersTo
-
Constructor Details
-
EquatableWeakReference
Creates a new weak reference that refers to the given object. The new reference is not registered with any queue.- Parameters:
referent
- object the new weak reference will refer to
-
EquatableWeakReference
Creates a new weak reference that refers to the given object and is registered with the given queue.- Parameters:
referent
- object the new weak reference will refer toq
- the queue with which the reference is to be registered, ornull
if registration is not required
-
-
Method Details
-
from
-
tryMakeStrong
Attempts to make this reference strong.- Returns:
- Whether or not this operation was successful. It will fail if the object was already disposed of.
- Throws:
IllegalStateException
- If this is already strong.
-
makeWeak
Returns this reference to its weak state.- Throws:
IllegalStateException
- If the reference is already marked as weak.
-
isStrong
public boolean isStrong() -
equals
-