Repository: yegor256/cactoos
Pull request #19 (2017-05-25 18:41:26)

#18: AnyOf, AllOf
As per #18 

 * `AllOf` and `AnyOf` introduced
 * `Proc` interface added
 * `ProcAsFunc` created


Patch:
diff --git a/README.md b/README.md
index 2237b902..0fe21e22 100644
--- a/README.md
+++ b/README.md
@@ -134,12 +134,23 @@ new IterableAsCollection<>(
 To iterate a collection:
 
 ```java
-new Loop(
+new AllOf(
   new TransformedIterable<>(
     new ArrayAsIterable<>("how", "are", "you"),
-    i -> System.out.printf("Item: %s\n", i)
+    new ProcAsFunc<>(
+      i -> System.out.printf("Item: %s\n", i)
+    )
   )
-).run();
+).asValue();
+```
+
+Or even more compact:
+
+```java
+new IterableAsBoolean(
+  new ArrayAsIterable<>("how", "are", "you"),
+  i -> System.out.printf("Item: %s\n", i)
+).asValue();
 ```
 
 To sort a list of words in the file:
diff --git a/src/main/java/org/cactoos/Proc.java b/src/main/java/org/cactoos/Proc.java
new file mode 100644
index 00000000..2e3ac730
--- /dev/null
+++ b/src/main/java/org/cactoos/Proc.java
@@ -0,0 +1,47 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos;
+
+import java.io.IOException;
+
+/**
+ * Procedure.
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @param <X> Type of input
+ * @since 0.1
+ */
+public interface Proc<X> {
+
+    /**
+     * Apply it.
+     * @param input The argument
+     * @throws IOException If fails
+     */
+    void apply(X input) throws IOException;
+
+}
diff --git a/src/main/java/org/cactoos/func/ConstFunc.java b/src/main/java/org/cactoos/func/ConstFunc.java
new file mode 100644
index 00000000..ae7d5cef
--- /dev/null
+++ b/src/main/java/org/cactoos/func/ConstFunc.java
@@ -0,0 +1,59 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.func;
+
+import org.cactoos.Func;
+
+/**
+ * Func that always returns the same result
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @param <X> Type of input
+ * @param <Y> Type of output
+ * @since 0.1
+ */
+public final class ConstFunc<X, Y> implements Func<X, Y> {
+
+    /**
+     * The result to return.
+     */
+    private final Y result;
+
+    /**
+     * Ctor.
+     * @param rslt What to return
+     */
+    public ConstFunc(final Y rslt) {
+        this.result = rslt;
+    }
+
+    @Override
+    public Y apply(final X input) {
+        return this.result;
+    }
+
+}
diff --git a/src/main/java/org/cactoos/func/DeadProc.java b/src/main/java/org/cactoos/func/DeadProc.java
new file mode 100644
index 00000000..b81510e4
--- /dev/null
+++ b/src/main/java/org/cactoos/func/DeadProc.java
@@ -0,0 +1,45 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.func;
+
+import org.cactoos.Proc;
+
+/**
+ * Proc that does nothing.
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @param <T> Type of items
+ * @since 0.1
+ */
+public final class DeadProc<T> implements Proc<T> {
+
+    @Override
+    public void apply(final T input) {
+        // nothing to do
+    }
+
+}
diff --git a/src/main/java/org/cactoos/func/ProcAsFunc.java b/src/main/java/org/cactoos/func/ProcAsFunc.java
new file mode 100644
index 00000000..0344f3c5
--- /dev/null
+++ b/src/main/java/org/cactoos/func/ProcAsFunc.java
@@ -0,0 +1,85 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.func;
+
+import java.io.IOException;
+import org.cactoos.Func;
+import org.cactoos.Proc;
+
+/**
+ * Proc that is a {@link Func} that returns {@code boolean}.
+ *
+ * <p>You may need this class when you iterate a collection, for example:</p>
+ *
+ * <pre> new AllOf(
+ *   new TransformedIterable&lt;String&gt;(
+ *     Arrays.asList("hello", "world"),
+ *     new ProcAsFunc(i -> System.out.println(i))
+ *   )
+ * ).asValue();</pre>
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @param <T> Type of items
+ * @since 0.1
+ */
+public final class ProcAsFunc<T> implements Func<T, Boolean> {
+
+    /**
+     * Proc.
+     */
+    private final Proc<T> proc;
+
+    /**
+     * The result to return.
+     */
+    private final Boolean result;
+
+    /**
+     * Ctor.
+     * @param cns Consumer
+     */
+    public ProcAsFunc(final Proc<T> cns) {
+        this(cns, true);
+    }
+
+    /**
+     * Ctor.
+     * @param cns Consumer
+     * @param rslt Result to return
+     */
+    public ProcAsFunc(final Proc<T> cns, final Boolean rslt) {
+        this.proc = cns;
+        this.result = rslt;
+    }
+
+    @Override
+    public Boolean apply(final T input) throws IOException {
+        this.proc.apply(input);
+        return this.result;
+    }
+
+}
diff --git a/src/main/java/org/cactoos/func/package-info.java b/src/main/java/org/cactoos/func/package-info.java
new file mode 100644
index 00000000..61d24438
--- /dev/null
+++ b/src/main/java/org/cactoos/func/package-info.java
@@ -0,0 +1,32 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
+ * Functions and procedures.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @since 0.1
+ */
+package org.cactoos.func;
diff --git a/src/main/java/org/cactoos/list/AllOf.java b/src/main/java/org/cactoos/list/AllOf.java
new file mode 100644
index 00000000..227f875a
--- /dev/null
+++ b/src/main/java/org/cactoos/list/AllOf.java
@@ -0,0 +1,92 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.list;
+
+import org.cactoos.Scalar;
+
+/**
+ * Is {@code true} when all items in the collection are {@code true}.
+ *
+ * <p>You can use this class in order to iterate all items
+ * in the collection. This is very similar to the {@code forEach()}
+ * in steams, but more object oriented. For example, if you want
+ * to print all items from the array:</p>
+ *
+ * <pre> new AllOf(
+ *   new TransformedIterable&lt;String&gt;(
+ *     Arrays.asList("hello", "world"),
+ *     new ProcAsFunc&lt;&gt;(i -> System.out.println(i))
+ *   )
+ * ).asValue();</pre>
+ *
+ * <p>Or even more compact, through {@link IterableAsBooleans}:</p>
+ *
+ * <pre> new AllOf(
+ *   new IterableAsBooleans&lt;String&gt;(
+ *     Arrays.asList("hello", "world"),
+ *     i -> System.out.println(i)
+ *   )
+ * ).asValue();</pre>
+ *
+ * <p>Or you can even use {@link IterableAsBoolean}:</p>
+ *
+ * <pre> new IterableAsBoolean&lt;String&gt;(
+ *   Arrays.asList("hello", "world"),
+ *   i -> System.out.println(i)
+ * ).asValue();</pre>
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @since 0.1
+ */
+public final class AllOf implements Scalar<Boolean> {
+
+    /**
+     * Iterable.
+     */
+    private final Iterable<Boolean> iterable;
+
+    /**
+     * Ctor.
+     * @param src Source iterable
+     */
+    public AllOf(final Iterable<Boolean> src) {
+        this.iterable = src;
+    }
+
+    @Override
+    public Boolean asValue() {
+        boolean success = true;
+        for (final Boolean item : this.iterable) {
+            if (!item) {
+                success = false;
+                break;
+            }
+        }
+        return success;
+    }
+
+}
diff --git a/src/main/java/org/cactoos/list/AnyOf.java b/src/main/java/org/cactoos/list/AnyOf.java
new file mode 100644
index 00000000..a08b63a7
--- /dev/null
+++ b/src/main/java/org/cactoos/list/AnyOf.java
@@ -0,0 +1,64 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.list;
+
+import org.cactoos.Scalar;
+
+/**
+ * Is {@code true} when any item in the collection is {@code true}.
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @since 0.1
+ */
+public final class AnyOf implements Scalar<Boolean> {
+
+    /**
+     * Iterable.
+     */
+    private final Iterable<Boolean> iterable;
+
+    /**
+     * Ctor.
+     * @param src Source iterable
+     */
+    public AnyOf(final Iterable<Boolean> src) {
+        this.iterable = src;
+    }
+
+    @Override
+    public Boolean asValue() {
+        boolean success = false;
+        for (final Boolean item : this.iterable) {
+            if (item) {
+                success = true;
+                break;
+            }
+        }
+        return success;
+    }
+
+}
diff --git a/src/main/java/org/cactoos/list/IterableAsBoolean.java b/src/main/java/org/cactoos/list/IterableAsBoolean.java
new file mode 100644
index 00000000..310fdf64
--- /dev/null
+++ b/src/main/java/org/cactoos/list/IterableAsBoolean.java
@@ -0,0 +1,78 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.list;
+
+import org.cactoos.Proc;
+import org.cactoos.Scalar;
+
+/**
+ * Iterable into boolean.
+ *
+ * <p>You can use this class, for example, in order to iterate through
+ * a collection of items:</p>
+ *
+ * <pre> new IterableAsBoolean&lt;&gt;(
+ *   Arrays.asList("hello", "world"),
+ *   i -> System.out.println(i)
+ * ).asValue();</pre>
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @param <X> Type of source item
+ * @since 0.1
+ */
+public final class IterableAsBoolean<X> implements Scalar<Boolean> {
+
+    /**
+     * Iterable.
+     */
+    private final Iterable<X> iterable;
+
+    /**
+     * Proc.
+     */
+    private final Proc<X> proc;
+
+    /**
+     * Ctor.
+     * @param src Source iterable
+     * @param prc Func
+     */
+    public IterableAsBoolean(final Iterable<X> src, final Proc<X> prc) {
+        this.iterable = src;
+        this.proc = prc;
+    }
+
+    @Override
+    public Boolean asValue() {
+        return new AllOf(
+            new IterableAsBooleans<>(
+                this.iterable,
+                this.proc
+            )
+        ).asValue();
+    }
+}
diff --git a/src/main/java/org/cactoos/list/IterableAsBooleans.java b/src/main/java/org/cactoos/list/IterableAsBooleans.java
new file mode 100644
index 00000000..186aeb88
--- /dev/null
+++ b/src/main/java/org/cactoos/list/IterableAsBooleans.java
@@ -0,0 +1,82 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.list;
+
+import java.util.Iterator;
+import org.cactoos.Proc;
+import org.cactoos.func.ProcAsFunc;
+
+/**
+ * Iterable into booleans.
+ *
+ * <p>You can use this class, for example, in order to iterate through
+ * a collection of items, in combination with {@link AllOf}:</p>
+ *
+ * <pre> new AllOf(
+ *   new IterableAsBooleans&lt;String&gt;(
+ *     Arrays.asList("hello", "world"),
+ *     i -> System.out.println(i)
+ *   )
+ * ).asValue();</pre>
+ *
+ * <p>Also, consider a much shorter version with {@link IterableAsBoolean}.</p>
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @param <X> Type of source item
+ * @since 0.1
+ */
+public final class IterableAsBooleans<X> implements Iterable<Boolean> {
+
+    /**
+     * Iterable.
+     */
+    private final Iterable<X> iterable;
+
+    /**
+     * Proc.
+     */
+    private final Proc<X> proc;
+
+    /**
+     * Ctor.
+     * @param src Source iterable
+     * @param prc Func
+     */
+    public IterableAsBooleans(final Iterable<X> src, final Proc<X> prc) {
+        this.iterable = src;
+        this.proc = prc;
+    }
+
+    @Override
+    public Iterator<Boolean> iterator() {
+        return new TransformedIterator<>(
+            this.iterable.iterator(),
+            new ProcAsFunc<X>(this.proc)
+        );
+    }
+
+}


Test patch:
diff --git a/src/test/java/org/cactoos/list/AllOfTest.java b/src/test/java/org/cactoos/list/AllOfTest.java
new file mode 100644
index 00000000..758bbf23
--- /dev/null
+++ b/src/test/java/org/cactoos/list/AllOfTest.java
@@ -0,0 +1,82 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.list;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import org.cactoos.func.ProcAsFunc;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+/**
+ * Test case for {@link AllOf}.
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @since 0.1
+ */
+public final class AllOfTest {
+
+    /**
+     * AllOf can test all items in the list.
+     */
+    @Test
+    public void iteratesList() {
+        final List<String> list = new LinkedList<>();
+        MatcherAssert.assertThat(
+            new AllOf(
+                new TransformedIterable<>(
+                    new ArrayAsIterable<>("hello", "world"),
+                    new ProcAsFunc<>(list::add)
+                )
+            ).asValue(),
+            Matchers.allOf(
+                Matchers.equalTo(true),
+                Matchers.equalTo(list.size() == 2)
+            )
+        );
+    }
+
+    /**
+     * AllOf can test all items in the list.
+     */
+    @Test
+    public void iteratesEmptyList() {
+        final List<String> list = new LinkedList<>();
+        MatcherAssert.assertThat(
+            new AllOf(
+                new IterableAsBooleans<String>(
+                    Collections.emptyList(),
+                    list::add
+                )
+            ).asValue(),
+            Matchers.allOf(
+                Matchers.equalTo(true),
+                Matchers.equalTo(list.isEmpty())
+            )
+        );
+    }
+
+}
diff --git a/src/test/java/org/cactoos/list/AnyOfTest.java b/src/test/java/org/cactoos/list/AnyOfTest.java
new file mode 100644
index 00000000..8748bb01
--- /dev/null
+++ b/src/test/java/org/cactoos/list/AnyOfTest.java
@@ -0,0 +1,54 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.list;
+
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+/**
+ * Test case for {@link AnyOf}.
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @since 0.1
+ */
+public final class AnyOfTest {
+
+    /**
+     * AnyOf can test any item in the list.
+     */
+    @Test
+    public void iteratesList() {
+        MatcherAssert.assertThat(
+            new AnyOf(
+                new TransformedIterable<>(
+                    new ArrayAsIterable<>("a", "file", "is", "corrupt"),
+                    txt -> txt.length() > 2
+                )
+            ).asValue(),
+            Matchers.equalTo(true)
+        );
+    }
+
+}