Class OnceUntil<T>
java.lang.Object
microsim.caching.OnceUntil<T>
- All Implemented Interfaces:
Supplier<T>
Cache the result of a Supplier so that it is only called only once until
the condition becomes true.
This requires the wrapped Supplier to return a non-null object. This is
lazy in the sense that the wrapped Supplier is only called when the value
is requested (either for the first time or when the simulation time
has changed).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget()Get the value.static <T> OnceUntil<T> timeChanges(Supplier<? extends T> supplier, SimulationEngine engine) Build a cache that updates once per simulation tick.
-
Constructor Details
-
OnceUntil
-
-
Method Details
-
timeChanges
Build a cache that updates once per simulation tick.
This is provided for convenience as this is a common caching condition.
-
get
-