T
- Type of resultpublic final class Constant<T> extends Object implements Scalar<T>
This Scalar
represents a constant value which never changes.
Contrary to Sticky
this constant is always
pre-computed.
This class implements Scalar
, which throws a checked
Exception
. Despite that this class does NOT throw a checked
exception as it only returns a pre-computed value.
Example:
final Scalar<String> constant = new Constant<>("Value");
System.out.print("Constant is always the same: ");
System.out.println(constant.value() == constant.value());
This class is thread-safe.
Sticky
Copyright © 2017–2020 Cactoos. All rights reserved.