Package org.cactoos.scalar
Class Sticky<T>
- java.lang.Object
-
- org.cactoos.scalar.Sticky<T>
-
- Type Parameters:
T
- Type of result
- All Implemented Interfaces:
Scalar<T>
public final class Sticky<T> extends Object implements Scalar<T>
Cached version of a Scalar.This
Scalar
decorator technically is an in-memory cache.Pay attention that this class is not thread-safe. It is highly recommended to always decorate it with
Synced
.This class implements
Scalar
, which throws a checkedException
. This may not be convenient in many cases. To make it more convenient and get rid of the checked exception you can use theUnchecked
decorator. Or you may useIoChecked
to wrap it in an IOException.final Scalar<Integer> scalar = new StickyScalar<>( () -> { System.out.println("Will be printed only once"); return new SecureRandom().nextInt(); } ).value()
There is no thread-safety guarantee.
- Since:
- 0.3
- See Also:
StickyFunc