Package org.cactoos.scalar
Class Ternary<T>
- java.lang.Object
-
- org.cactoos.scalar.ScalarEnvelope<T>
-
- org.cactoos.scalar.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 checkedException
. This may not be convenient in many cases. To make it more convenient and get rid of the checked exception you can use theUnchecked
decorator. Or you may useIoChecked
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 Summary
Constructors Constructor Description Ternary(boolean cnd, Scalar<? extends T> cons, Scalar<? extends T> alter)
Ctor.Ternary(boolean cnd, T cons, T alter)
Ctor.Ternary(Scalar<? extends X> input, Func<? super X,Boolean> cnd, Func<? super X,? extends T> cons, Func<? super X,? extends T> alter)
Ctor.Ternary(Scalar<Boolean> cnd, Scalar<? extends T> cons, Scalar<? extends T> alter)
Ctor.Ternary(Scalar<Boolean> cnd, T cons, T alter)
Ctor.Ternary(X input, Func<? super X,Boolean> cnd, Func<? super X,? extends T> cons, Func<? super X,? extends T> alter)
Ctor.
-
-
-
Constructor Detail
-
Ternary
public Ternary(boolean cnd, T cons, T alter)
Ctor.- Parameters:
cnd
- The conditioncons
- The consequentalter
- The alternative- Since:
- 0.9
-
Ternary
public Ternary(Scalar<Boolean> cnd, T cons, T alter)
Ctor.- Parameters:
cnd
- The conditioncons
- The consequentalter
- The alternative
-
Ternary
public Ternary(boolean cnd, Scalar<? extends T> cons, Scalar<? extends T> alter)
Ctor.- Parameters:
cnd
- The conditioncons
- The consequentalter
- The alternative- Since:
- 0.9
-
Ternary
public Ternary(Scalar<Boolean> cnd, Scalar<? extends T> cons, Scalar<? extends T> alter)
Ctor.- Parameters:
cnd
- The conditioncons
- The consequentalter
- 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 themcnd
- The conditioncons
- The consequentalter
- 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 themcnd
- The conditioncons
- The consequentalter
- The alternative- Since:
- 0.9
-
-