Class Constant<T>

  • Type Parameters:
    T - Type of result
    All Implemented Interfaces:
    Scalar<T>

    public final class Constant<T>
    extends Object
    implements Scalar<T>
    Constant value.

    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.

    Since:
    0.30
    See Also:
    Sticky
    • Constructor Detail

      • Constant

        public Constant​(T value)
        Ctor.
        Parameters:
        value - The pre-computed constant.
    • Method Detail

      • value

        public T value()
        Description copied from interface: Scalar
        Convert it to the value.
        Specified by:
        value in interface Scalar<T>
        Returns:
        The value