Package alexiil.mc.lib.attributes.misc
Class SimulatableRef<T>
java.lang.Object
alexiil.mc.lib.attributes.misc.SimulatableRef<T>
- All Implemented Interfaces:
Reference<T>
public final class SimulatableRef<T> extends java.lang.Object implements Reference<T>
A variant of
CallableRef
that uses Supplier
for get()
, and LimitedConsumer
for
set(Object)
and isValid(Object)
.-
Constructor Summary
Constructors Constructor Description SimulatableRef(java.util.function.Supplier<T> getter, LimitedConsumer<T> setter)
-
Method Summary
Modifier and Type Method Description T
get()
boolean
isValid(T value)
boolean
set(T value)
boolean
set(T value, Simulation simulation)
Delegates toReference.set(Object)
if the simulation isSimulation.ACTION
, otherwise it delegates toReference.isValid(Object)
.
-
Constructor Details
-
Method Details
-
get
- Specified by:
get
in interfaceReference<T>
- Returns:
- The object referenced. Note that you should generally not modify the returned value directly - instead
copy it before passing it to
Reference.set(Object)
orReference.isValid(Object)
to see if your modifications are permitted.
-
set
-
isValid
- Specified by:
isValid
in interfaceReference<T>
- Returns:
- True if
Reference.set(Object)
was called with the same value.
-
set
Description copied from interface:Reference
Delegates toReference.set(Object)
if the simulation isSimulation.ACTION
, otherwise it delegates toReference.isValid(Object)
.
-