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 UncheckedScalar
or IoCheckedScalar
decorators.
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
Scalar.NoNulls<T>
Constructor and Description |
---|
StickyScalar(Scalar<T> scalar)
Ctor.
|
Copyright © 2017–2018 Cactoos. All rights reserved.