public class CopyRef<T extends Copyable<T>> extends java.lang.Object implements IReference<T>
As the object is copied once incoming and each time it is requested this reference is used most efficiently for basically mutable objects which implement an immutable interface. Copying should then return an immutable object which no longer require copying. Then no more than one copy operation has to happen when using this reference.
NULL_REF
Constructor and Description |
---|
CopyRef(T object,
java.util.function.UnaryOperator<T> copier)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
T |
get()
Get the referenced object.
|
<R extends Copyable<R>> |
make(R object)
Create a copy reference for a copyable object.
|
<R extends Copyable<R>> |
makeN(R object)
Create a reference of a copyable object which might be
null . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
hard, nullRef, soft, weak
@NotNull public T get()
IReference
null
if the referenced
object is garbage collected or this is a null reference
.get
in interface IReference<T extends Copyable<T>>
null
@NotNull public <R extends Copyable<R>> CopyRef<R> make(@NotNull R object)
R
- object typeobject
- copyable object@NotNull public <R extends Copyable<R>> IReference<R> makeN(@Nullable R object)
null
.R
- object typeobject
- copyable objectnull reference
if object is null