T
- Type of resultpublic final class StickyScalar<T> extends Object implements Scalar<T>
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 SyncScalar
.
This class implements Scalar
, which throws a checked
Exception
. This may not be convenient in many cases. To make
it more convenient and get rid of the checked exception you can
use the UncheckedScalar
decorator. Or you may use
IoCheckedScalar
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.
StickyFunc
Constructor and Description |
---|
StickyScalar(Scalar<T> scalar)
Ctor.
|
Copyright © 2017–2019 Cactoos. All rights reserved.