Class Memoized<T>

java.lang.Object
nl.colorize.util.Memoized<T>
Type Parameters:
T - The type of value that is returned by the operation.
All Implemented Interfaces:
Supplier<T>

public final class Memoized<T> extends Object implements Supplier<T>
Wraps a computationally expensive operation so that the result is only calculated on the first call, and the cached result is returned for subsequent calls. Evaluation is lazy, the operation is not actually performed until get() is called for the first time.

This class is intended for caching single values. Use Cache for caching multiple values based on a cache key.

Instances of this class are not thread-safe. This class is not intended for situations where the expensive operation is performed by one thread, and the result is processed by a different thread. In those situations, use Subject or a similar asynchronous mechanism.