Package org.cactoos.scalar
Class Xor
- java.lang.Object
-
- org.cactoos.scalar.ScalarEnvelope<Boolean>
-
- org.cactoos.scalar.Xor
-
public final class Xor extends ScalarEnvelope<Boolean>
Logical exclusive or. ReturnsTrue
when an odd number of elements have value true, otherwise returnFalse
.This class could be also used for matching multiple boolean expressions:
new Xor( new True(), new True(), new True() ).value(); // the result is true new Xor( new True(), new False(), new True() ).value(); // the result is false
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.There is no thread-safety guarantee.