Class Ternary<T>

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

    public final class Ternary<T>
    extends ScalarEnvelope<T>
    Ternary operation.

    There is no thread-safety guarantee.

    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 Unchecked decorator. Or you may use IoChecked to wrap it in an IOException.

    
     new Ternary<>(
         scalar,
         value -> value > 3,
         value -> true,
         value -> false
     ).value() // will be equal to true
     
    Since:
    0.8
    • Constructor Detail

      • Ternary

        public Ternary​(boolean cnd,
                       T cons,
                       T alter)
        Ctor.
        Parameters:
        cnd - The condition
        cons - The consequent
        alter - The alternative
        Since:
        0.9
      • Ternary

        public Ternary​(Scalar<Boolean> cnd,
                       T cons,
                       T alter)
        Ctor.
        Parameters:
        cnd - The condition
        cons - The consequent
        alter - The alternative
      • Ternary

        public Ternary​(boolean cnd,
                       Scalar<? extends T> cons,
                       Scalar<? extends T> alter)
        Ctor.
        Parameters:
        cnd - The condition
        cons - The consequent
        alter - The alternative
        Since:
        0.9
      • Ternary

        public Ternary​(Scalar<Boolean> cnd,
                       Scalar<? extends T> cons,
                       Scalar<? extends T> alter)
        Ctor.
        Parameters:
        cnd - The condition
        cons - The consequent
        alter - The alternative
        Since:
        0.9
      • Ternary

        public Ternary​(X input,
                       Func<? super X,​Boolean> cnd,
                       Func<? super X,​? extends T> cons,
                       Func<? super X,​? extends T> alter)
        Ctor.
        Type Parameters:
        X - Type of input
        Parameters:
        input - The input to pass to all of them
        cnd - The condition
        cons - The consequent
        alter - The alternative
        Since:
        0.9
      • Ternary

        public Ternary​(Scalar<? extends X> input,
                       Func<? super X,​Boolean> cnd,
                       Func<? super X,​? extends T> cons,
                       Func<? super X,​? extends T> alter)
        Ctor.
        Type Parameters:
        X - Type of input
        Parameters:
        input - The input to pass to all of them
        cnd - The condition
        cons - The consequent
        alter - The alternative
        Since:
        0.9