T - type of referenced object@FunctionalInterface
public interface IReference<T>
Reference,
but implemented as an interface to also allow hard
references and more.| Modifier and Type | Field and Description |
|---|---|
static IReference<?> |
NULL_REF
Null reference.
|
| Modifier and Type | Method and Description |
|---|---|
T |
get()
Get the referenced object.
|
static <R> IReference<R> |
hard(R obj)
Get a hard reference.
|
default boolean |
isNull()
Is this the null reference?
|
static <R> IReference<R> |
nullRef()
Get a null reference.
|
static <R> IReference<R> |
soft(R obj)
Get a soft reference.
|
static <R> IReference<R> |
weak(R obj)
Get a weak reference.
|
static final IReference<?> NULL_REF
@Nullable T get()
null if the referenced
object is garbage collected or this is a null reference.nulldefault boolean isNull()
true: this is the null reference,
so returning null is its purposefalse: this is not the null reference,
so returning null means the original object
is garbage collected and gone to object nirvana@NotNull static <R> IReference<R> nullRef()
R - referenced typenull@NotNull static <R> IReference<R> hard(@Nullable R obj)
R - referenced typeobj - object to be referenced@NotNull static <R> IReference<R> soft(@Nullable R obj)
SoftReference.R - referenced typeobj - object to be referenced@NotNull static <R> IReference<R> weak(@Nullable R obj)
WeakReference.R - referenced typeobj - object to be referenced