public final class And extends Object implements Scalar<Boolean>
This class can be effectively used to iterate through
a collection, just like
Stream.forEach(java.util.function.Consumer)
works:
new And(
new ProcOf<>(input -> System.out.printf("\'%s\' ", input)),
new IterableOf<>("Mary", "John", "William", "Napkin")
).value(); // will print 'Mary' 'John' 'William' 'Napkin' to standard output
// the result of this operation is always true
This class could be also used for matching multiple boolean expressions:
new And(
new True(),
new True(),
new True()
).value(); // the result is true
new And(
new True(),
new False(),
new True()
).value(); // the result is false
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 UncheckedScalar
decorator. Or you may use
IoCheckedScalar
to wrap it in an IOException.
There is no thread-safety guarantee.
UncheckedScalar
,
IoCheckedScalar
Constructor and Description |
---|
And(Func<X,Boolean> func,
Iterable<X> src)
Ctor.
|
And(Func<X,Boolean> func,
Iterator<X> src)
Ctor.
|
And(Func<X,Boolean> func,
X... src)
Ctor.
|
And(Iterable<Scalar<Boolean>> iterable)
Ctor.
|
And(Iterator<Scalar<Boolean>> iterator)
Ctor.
|
And(Proc<X> proc,
Iterable<X> src)
Ctor.
|
And(Proc<X> proc,
Iterator<X> src)
Ctor.
|
And(Proc<X> proc,
X... src)
Ctor.
|
And(Scalar<Boolean>... scalar)
Ctor.
|
And(X subject,
Func<X,Boolean>... conditions)
Ctor.
|
@SafeVarargs public And(Proc<X> proc, X... src)
X
- Type of items in the iterableproc
- Proc to mapsrc
- The iterable@SafeVarargs public And(Func<X,Boolean> func, X... src)
X
- Type of items in the iterablefunc
- Func to mapsrc
- The iterablepublic And(Proc<X> proc, Iterator<X> src)
X
- Type of items in the iteratorsrc
- The iteratorproc
- Proc to usepublic And(Proc<X> proc, Iterable<X> src)
X
- Type of items in the iterablesrc
- The iterableproc
- Proc to usepublic And(Func<X,Boolean> func, Iterator<X> src)
X
- Type of items in the iteratorsrc
- The iteratorfunc
- Func to mappublic And(Func<X,Boolean> func, Iterable<X> src)
X
- Type of items in the iterablesrc
- The iterablefunc
- Func to map@SafeVarargs public And(X subject, Func<X,Boolean>... conditions)
X
- Type of items in the iterablesubject
- The subjectconditions
- Funcs to map@SafeVarargs public And(Scalar<Boolean>... scalar)
scalar
- The Scalar.public And(Iterator<Scalar<Boolean>> iterator)
iterator
- The iterator.Copyright © 2017–2019 Cactoos. All rights reserved.