Repository: yegor256/cactoos
Pull request #73 (2017-06-02 08:41:30)

Replaced Text
Replaces the text


Patch:
diff --git a/.travis.yml b/.travis.yml
index 297e4b6c..37963f66 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,6 @@ cache:
 script:
   - set -e
   - mvn clean install -Pqulice --errors --batch-mode
-  - mvn clean site -Psite --errors --batch-mode
 env:
   global:
     - MAVEN_OPTS="-Xmx256m"
diff --git a/src/main/java/org/cactoos/Func.java b/src/main/java/org/cactoos/Func.java
index aaad18c3..46d48913 100644
--- a/src/main/java/org/cactoos/Func.java
+++ b/src/main/java/org/cactoos/Func.java
@@ -23,6 +23,8 @@
  */
 package org.cactoos;
 
+import java.util.concurrent.Callable;
+
 /**
  * Function.
  *
@@ -45,4 +47,102 @@ public interface Func<X, Y> {
      */
     Y apply(X input) throws Exception;
 
+    /**
+     * Func that doesn't throw.
+     * @param <X> Input type
+     * @param <Y> Output type
+     */
+    interface Safe<X, Y> extends Func<X, Y> {
+        /**
+         * Apply it safely.
+         * @param input The argument
+         * @return The result
+         */
+        @SuppressWarnings("PMD.AvoidCatchingGenericException")
+        default Y safeApply(X input) {
+            try {
+                return this.apply(input);
+            } catch (final InterruptedException ex) {
+                Thread.currentThread().interrupt();
+                throw new IllegalStateException(ex);
+                // @checkstyle IllegalCatchCheck (1 line)
+            } catch (final Exception ex) {
+                throw new IllegalStateException(ex);
+            }
+        }
+    }
+
+    /**
+     * Quiet func that returns nothing, but is still a function.
+     * @param <X> Input type
+     */
+    interface Quiet<X> extends Func<X, Boolean> {
+        @Override
+        default Boolean apply(X input) throws Exception {
+            this.exec(input);
+            return true;
+        }
+        /**
+         * Execute it.
+         * @param input The argument
+         * @throws Exception If fails
+         */
+        void exec(X input) throws Exception;
+    }
+
+    /**
+     * Func that returns something but doesn't expect any input.
+     * @param <Y> Output type
+     */
+    interface Value<Y> extends Func<Void, Y>, Scalar<Y>, Callable<Y> {
+        @Override
+        default Y apply(Void input) throws Exception {
+            return this.asValue();
+        }
+        @Override
+        default Y call() throws Exception {
+            return this.asValue();
+        }
+    }
+
+    /**
+     * Func that really is a procedure that does something and returns nothing.
+     */
+    interface Proc extends Func<Boolean, Boolean>, Runnable, Callable<Boolean> {
+        @Override
+        default Boolean apply(Boolean input) throws Exception {
+            return this.call();
+        }
+        @Override
+        default Boolean call() throws Exception {
+            this.run();
+            return true;
+        }
+        @Override
+        @SuppressWarnings("PMD.AvoidCatchingGenericException")
+        default void run() {
+            try {
+                this.exec();
+            } catch (final InterruptedException ex) {
+                Thread.currentThread().interrupt();
+                throw new IllegalStateException(ex);
+                // @checkstyle IllegalCatchCheck (1 line)
+            } catch (final Exception ex) {
+                throw new IllegalStateException(ex);
+            }
+        }
+        /**
+         * Execute it.
+         * @throws Exception If fails
+         */
+        void exec() throws Exception;
+    }
+
+    /**
+     * Func that represents a predicate of one argument.
+     * @param <X> Input type
+     */
+    interface Pred<X> extends Func<X, Boolean> {
+    }
+
 }
diff --git a/src/main/java/org/cactoos/FuncApplies.java b/src/main/java/org/cactoos/FuncApplies.java
deleted file mode 100644
index 96983eef..00000000
--- a/src/main/java/org/cactoos/FuncApplies.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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 org.cactoos.func.UncheckedFunc;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.hamcrest.TypeSafeMatcher;
-import org.hamcrest.core.IsEqual;
-
-/**
- * Matcher for the value.
- *
- * @author Yegor Bugayenko (yegor256@gmail.com)
- * @version $Id$
- * @param <X> Type of input
- * @param <Y> Type of output
- * @since 0.2
- */
-public final class FuncApplies<X, Y> extends TypeSafeMatcher<Func<X, Y>> {
-
-    /**
-     * Input of the function.
-     */
-    private final X input;
-
-    /**
-     * Matcher of the result.
-     */
-    private final Matcher<Y> matcher;
-
-    /**
-     * Ctor.
-     * @param result The result expected
-     * @param inpt Input for the function
-     */
-    public FuncApplies(final X inpt, final Y result) {
-        this(inpt, new IsEqual<>(result));
-    }
-
-    /**
-     * Ctor.
-     * @param inpt Input for the function
-     * @param mtr Matcher of the text
-     */
-    public FuncApplies(final X inpt, final Matcher<Y> mtr) {
-        super();
-        this.input = inpt;
-        this.matcher = mtr;
-    }
-
-    @Override
-    public boolean matchesSafely(final Func<X, Y> func) {
-        return this.matcher.matches(
-            new UncheckedFunc<>(func).apply(this.input)
-        );
-    }
-
-    @Override
-    public void describeTo(final Description description) {
-        description.appendText("Scalar with ");
-        description.appendDescriptionOf(this.matcher);
-    }
-}
diff --git a/src/main/java/org/cactoos/func/AlwaysTrueFunc.java b/src/main/java/org/cactoos/func/AlwaysTrueFunc.java
deleted file mode 100644
index 747b1e4f..00000000
--- a/src/main/java/org/cactoos/func/AlwaysTrueFunc.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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 as that is always true.
- *
- * <p>You may want to use this decorator when you need
- * a procedure that returns boolean instead of a function:</p>
- *
- * <pre> List&lt;String&gt; list = new LinkedList&lt;&gt;();
- * new AllOf(
- *   new IterableAsBooleans&lt;String&gt;(
- *     Collections.emptyList(),
- *     new AlwaysTrueFunc&lt;&gt;(list::add)
- *   )
- * ).asValue();
- * </pre>
- *
- * <p>There is no thread-safety guarantee.
- *
- * @author Yegor Bugayenko (yegor256@gmail.com)
- * @version $Id$
- * @param <X> Type of input
- * @since 0.2
- */
-public final class AlwaysTrueFunc<X> implements Func<X, Boolean> {
-
-    /**
-     * Original func.
-     */
-    private final Func<X, ?> func;
-
-    /**
-     * Ctor.
-     * @param fnc Encapsulated func
-     */
-    public AlwaysTrueFunc(final Func<X, ?> fnc) {
-        this.func = fnc;
-    }
-
-    @Override
-    public Boolean apply(final X input) throws Exception {
-        this.func.apply(input);
-        return true;
-    }
-
-}
diff --git a/src/main/java/org/cactoos/func/ConstFunc.java b/src/main/java/org/cactoos/func/ConstFunc.java
index 3f2c8dfb..ae7d5cef 100644
--- a/src/main/java/org/cactoos/func/ConstFunc.java
+++ b/src/main/java/org/cactoos/func/ConstFunc.java
@@ -26,7 +26,7 @@ package org.cactoos.func;
 import org.cactoos.Func;
 
 /**
- * Func that always returns the same result.
+ * Func that always returns the same result
  *
  * <p>There is no thread-safety guarantee.
  *
diff --git a/src/main/java/org/cactoos/func/FuncAsCallable.java b/src/main/java/org/cactoos/func/FuncAsCallable.java
deleted file mode 100644
index 2862f574..00000000
--- a/src/main/java/org/cactoos/func/FuncAsCallable.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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.util.concurrent.Callable;
-import org.cactoos.Func;
-
-/**
- * Func as {@link Callable}.
- *
- * <p>You may want to use this decorator where
- * {@link Callable} is required, but you just have a function:</p>
- *
- * <pre> Callable&lt;String&gt; callable = new FuncAsCallable&lt;&gt;(
- *   i -&gt; "Hello, world!"
- * );
- * </pre>
- *
- * <p>There is no thread-safety guarantee.
- *
- * @author Yegor Bugayenko (yegor256@gmail.com)
- * @version $Id$
- * @param <T> Type of input
- * @since 0.2
- */
-public final class FuncAsCallable<T> implements Callable<T> {
-
-    /**
-     * Original func.
-     */
-    private final Func<?, T> func;
-
-    /**
-     * Ctor.
-     * @param fnc Encapsulated func
-     */
-    public FuncAsCallable(final Func<?, T> fnc) {
-        this.func = fnc;
-    }
-
-    @Override
-    public T call() throws Exception {
-        return this.func.apply(null);
-    }
-}
diff --git a/src/main/java/org/cactoos/func/FuncAsMatcher.java b/src/main/java/org/cactoos/func/FuncAsMatcher.java
index b7f31ebd..85f44845 100644
--- a/src/main/java/org/cactoos/func/FuncAsMatcher.java
+++ b/src/main/java/org/cactoos/func/FuncAsMatcher.java
@@ -54,8 +54,14 @@ public final class FuncAsMatcher<T> extends TypeSafeMatcher<T> {
     }
 
     @Override
+    @SuppressWarnings("PMD.AvoidCatchingGenericException")
     public boolean matchesSafely(final T item) {
-        return new UncheckedFunc<>(this.func).apply(item);
+        try {
+            return this.func.apply(item);
+            // @checkstyle IllegalCatchCheck (1 line)
+        } catch (final Exception ex) {
+            throw new AssertionError(ex);
+        }
     }
 
     @Override
diff --git a/src/main/java/org/cactoos/func/FuncAsRunnable.java b/src/main/java/org/cactoos/func/FuncAsProc.java
similarity index 85%
rename from src/main/java/org/cactoos/func/FuncAsRunnable.java
rename to src/main/java/org/cactoos/func/FuncAsProc.java
index 657c1357..7273728c 100644
--- a/src/main/java/org/cactoos/func/FuncAsRunnable.java
+++ b/src/main/java/org/cactoos/func/FuncAsProc.java
@@ -32,25 +32,26 @@ import org.cactoos.Func;
  *
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
- * @since 0.2
+ * @since 0.1
  */
-public final class FuncAsRunnable implements Runnable {
+public final class FuncAsProc implements Func.Proc {
 
     /**
-     * Original func.
+     * The func.
      */
     private final Func<?, ?> func;
 
     /**
      * Ctor.
-     * @param fnc Encapsulated func
+     * @param fnc The func
      */
-    public FuncAsRunnable(final Func<?, ?> fnc) {
+    public FuncAsProc(final Func<?, ?> fnc) {
         this.func = fnc;
     }
 
     @Override
-    public void run() {
-        new UncheckedFunc<>(this.func).apply(null);
+    public void exec() throws Exception {
+        this.func.apply(null);
     }
+
 }
diff --git a/src/main/java/org/cactoos/func/RunnableAsFunc.java b/src/main/java/org/cactoos/func/RunnableAsProc.java
similarity index 84%
rename from src/main/java/org/cactoos/func/RunnableAsFunc.java
rename to src/main/java/org/cactoos/func/RunnableAsProc.java
index 5cb6a170..114f51a3 100644
--- a/src/main/java/org/cactoos/func/RunnableAsFunc.java
+++ b/src/main/java/org/cactoos/func/RunnableAsProc.java
@@ -32,14 +32,9 @@ import org.cactoos.Func;
  *
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
- * @param <X> Type of input
- * @param <Y> Type of output
- * @see FuncAsCallable
- * @see FuncAsRunnable
- * @see CallableAsFunc
  * @since 0.2
  */
-public final class RunnableAsFunc<X, Y> implements Func<X, Y> {
+public final class RunnableAsProc implements Func.Proc {
 
     /**
      * The runnable.
@@ -50,13 +45,13 @@ public final class RunnableAsFunc<X, Y> implements Func<X, Y> {
      * Ctor.
      * @param rnbl The runnable
      */
-    public RunnableAsFunc(final Runnable rnbl) {
+    public RunnableAsProc(final Runnable rnbl) {
         this.runnable = rnbl;
     }
 
     @Override
-    public Y apply(final X input) {
+    public void exec() {
         this.runnable.run();
-        return null;
     }
+
 }
diff --git a/src/main/java/org/cactoos/func/UncheckedFunc.java b/src/main/java/org/cactoos/func/UncheckedFunc.java
deleted file mode 100644
index b6258247..00000000
--- a/src/main/java/org/cactoos/func/UncheckedFunc.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * 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 doesn't throw checked {@link Exception}.
- *
- * <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.2
- */
-public final class UncheckedFunc<X, Y> implements Func<X, Y> {
-
-    /**
-     * Original func.
-     */
-    private final Func<X, Y> func;
-
-    /**
-     * Ctor.
-     * @param fnc Encapsulated func
-     */
-    public UncheckedFunc(final Func<X, Y> fnc) {
-        this.func = fnc;
-    }
-
-    @Override
-    @SuppressWarnings("PMD.AvoidCatchingGenericException")
-    public Y apply(final X input) {
-        try {
-            return this.func.apply(input);
-        } catch (final InterruptedException ex) {
-            Thread.currentThread().interrupt();
-            throw new IllegalStateException(ex);
-            // @checkstyle IllegalCatchCheck (1 line)
-        } catch (final Exception ex) {
-            throw new IllegalStateException(ex);
-        }
-    }
-
-}
diff --git a/src/main/java/org/cactoos/list/FilteredIterable.java b/src/main/java/org/cactoos/list/FilteredIterable.java
index be6acb85..1a2292d0 100644
--- a/src/main/java/org/cactoos/list/FilteredIterable.java
+++ b/src/main/java/org/cactoos/list/FilteredIterable.java
@@ -29,24 +29,11 @@ import org.cactoos.Func;
 /**
  * Filtered iterable.
  *
- * <p>You can use it in order to create a declarative/lazy
- * version of a filtered collection/iterable. For example,
- * this code will create a list of two strings "hello" and "world":</p>
- *
- * <pre> Iterable&lt;String&gt; list = new FilteredIterable&lt;&gt;(
- *   new ArrayAsIterable&lt;&gt;(
- *     "hey", "hello", "world"
- *   ),
- *   input -&gt; input.length() &gt; 4
- * );
- * </pre>
- *
  * <p>There is no thread-safety guarantee.
  *
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @param <X> Type of item
- * @see FilteredIterator
  * @since 0.1
  */
 public final class FilteredIterable<X> implements Iterable<X> {
@@ -59,23 +46,23 @@ public final class FilteredIterable<X> implements Iterable<X> {
     /**
      * Function.
      */
-    private final Func<X, Boolean> func;
+    private final Func.Pred<X> pred;
 
     /**
      * Ctor.
      * @param src Source iterable
-     * @param fnc Predicate
+     * @param pred Predicate
      */
-    public FilteredIterable(final Iterable<X> src, final Func<X, Boolean> fnc) {
+    public FilteredIterable(final Iterable<X> src, final Func.Pred<X> pred) {
         this.iterable = src;
-        this.func = fnc;
+        this.pred = pred;
     }
 
     @Override
     public Iterator<X> iterator() {
         return new FilteredIterator<>(
             this.iterable.iterator(),
-            this.func
+            this.pred
         );
     }
 
diff --git a/src/main/java/org/cactoos/list/FilteredIterator.java b/src/main/java/org/cactoos/list/FilteredIterator.java
index a4c7739e..22f3b6d1 100644
--- a/src/main/java/org/cactoos/list/FilteredIterator.java
+++ b/src/main/java/org/cactoos/list/FilteredIterator.java
@@ -28,29 +28,15 @@ import java.util.LinkedList;
 import java.util.NoSuchElementException;
 import java.util.Queue;
 import org.cactoos.Func;
-import org.cactoos.func.UncheckedFunc;
 
 /**
  * Filtered iterator.
  *
- * <p>You can use it in order to create a declarative/lazy
- * version of a filtered collection/iterable. For example,
- * this code will create a list of two strings "hello" and "world":</p>
- *
- * <pre> Iterator&lt;String&gt; list = new FilteredIterator&lt;&gt;(
- *   new ArrayAsIterable&lt;&gt;(
- *     "hey", "hello", "world"
- *   ).iterator(),
- *   input -&gt; input.length() &gt; 4
- * );
- * </pre>
- *
  * <p>There is no thread-safety guarantee.
  *
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @param <X> Type of item
- * @see FilteredIterable
  * @since 0.1
  */
 public final class FilteredIterator<X> implements Iterator<X> {
@@ -63,7 +49,7 @@ public final class FilteredIterator<X> implements Iterator<X> {
     /**
      * Predicate.
      */
-    private final Func<X, Boolean> func;
+    private final Func.Pred<X> pred;
 
     /**
      * The buffer storing the objects of the iterator.
@@ -73,23 +59,28 @@ public final class FilteredIterator<X> implements Iterator<X> {
     /**
      * Ctor.
      * @param src Source iterable
-     * @param fnc Predicate
+     * @param pred Predicate
      */
-    public FilteredIterator(final Iterator<X> src, final Func<X, Boolean> fnc) {
+    public FilteredIterator(final Iterator<X> src, final Func.Pred<X> pred) {
         this.iterator = src;
-        this.func = fnc;
+        this.pred = pred;
         this.buffer = new LinkedList<>();
     }
 
     @Override
+    @SuppressWarnings("PMD.AvoidCatchingGenericException")
     public boolean hasNext() {
-        final UncheckedFunc<X, Boolean> fnc = new UncheckedFunc<>(this.func);
         if (this.buffer.isEmpty()) {
             while (this.iterator.hasNext()) {
                 final X object = this.iterator.next();
-                if (fnc.apply(object)) {
-                    this.buffer.add(object);
-                    break;
+                try {
+                    if (this.pred.apply(object)) {
+                        this.buffer.add(object);
+                        break;
+                    }
+                    // @checkstyle IllegalCatchCheck (1 line)
+                } catch (final Exception ex) {
+                    throw new IllegalStateException(ex);
                 }
             }
         }
diff --git a/src/main/java/org/cactoos/list/IterableAsBoolean.java b/src/main/java/org/cactoos/list/IterableAsBoolean.java
index 6352b4b8..31b91f4e 100644
--- a/src/main/java/org/cactoos/list/IterableAsBoolean.java
+++ b/src/main/java/org/cactoos/list/IterableAsBoolean.java
@@ -42,7 +42,6 @@ import org.cactoos.Scalar;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @param <X> Type of source item
- * @see IterableAsBooleans
  * @since 0.1
  */
 public final class IterableAsBoolean<X> implements Scalar<Boolean> {
diff --git a/src/main/java/org/cactoos/list/IterableAsBooleans.java b/src/main/java/org/cactoos/list/IterableAsBooleans.java
index 98c50a1c..ee1efd9c 100644
--- a/src/main/java/org/cactoos/list/IterableAsBooleans.java
+++ b/src/main/java/org/cactoos/list/IterableAsBooleans.java
@@ -46,7 +46,6 @@ import org.cactoos.Func;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @param <X> Type of source item
- * @see IterableAsBoolean
  * @since 0.1
  */
 public final class IterableAsBooleans<X> implements Iterable<Boolean> {
diff --git a/src/main/java/org/cactoos/list/TransformedIterator.java b/src/main/java/org/cactoos/list/TransformedIterator.java
index fe3424e5..b4768525 100644
--- a/src/main/java/org/cactoos/list/TransformedIterator.java
+++ b/src/main/java/org/cactoos/list/TransformedIterator.java
@@ -25,7 +25,6 @@ package org.cactoos.list;
 
 import java.util.Iterator;
 import org.cactoos.Func;
-import org.cactoos.func.UncheckedFunc;
 
 /**
  * Transformed iterator.
@@ -68,7 +67,12 @@ public final class TransformedIterator<X, Y> implements Iterator<Y> {
     @Override
     @SuppressWarnings("PMD.AvoidCatchingGenericException")
     public Y next() {
-        return new UncheckedFunc<>(this.func).apply(this.iterator.next());
+        try {
+            return this.func.apply(this.iterator.next());
+            // @checkstyle IllegalCatchCheck (1 line)
+        } catch (final Exception ex) {
+            throw new IllegalStateException(ex);
+        }
     }
 
     @Override
diff --git a/src/main/java/org/cactoos/package-info.java b/src/main/java/org/cactoos/package-info.java
index fce172b3..0fea2db6 100644
--- a/src/main/java/org/cactoos/package-info.java
+++ b/src/main/java/org/cactoos/package-info.java
@@ -25,17 +25,9 @@
 /**
  * Cactoos.
  *
- * <p>This is a collection of Java primitives designed in a rather
- * extreme object-objected manner. More details about our design
- * decisions you can find in this
- * <a href="https://github.com/yegor256/cactoos/blob/master/README.md">README</a>.
- * Feel free to contribute, if you find issues or have a need for
- * some other primitives.</p>
- *
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
- * @see <a href="http://www.cactoos.org">Project site www.cactoos.org</a>
- * @see <a href="https://github.com/yegor256/cactoos">GitHub repository</a>
+ * @see <a href="http://www.takes.org">project site www.cactoos.org</a>
  */
 package org.cactoos;
diff --git a/src/main/java/org/cactoos/func/CallableAsFunc.java b/src/main/java/org/cactoos/text/ReplacedText.java
similarity index 61%
rename from src/main/java/org/cactoos/func/CallableAsFunc.java
rename to src/main/java/org/cactoos/text/ReplacedText.java
index e5c3c7a6..0f95b083 100644
--- a/src/main/java/org/cactoos/func/CallableAsFunc.java
+++ b/src/main/java/org/cactoos/text/ReplacedText.java
@@ -21,42 +21,51 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-package org.cactoos.func;
+package org.cactoos.text;
 
-import java.util.concurrent.Callable;
-import org.cactoos.Func;
+import java.io.IOException;
+import org.cactoos.Text;
 
 /**
- * Callable as Func.
+ * Replace the Text.
  *
- * <p>There is no thread-safety guarantee.
- *
- * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @author Mehmet Yildirim (memoyil@gmail.com)
  * @version $Id$
- * @param <X> Type of input
- * @param <Y> Type of output
- * @see FuncAsCallable
- * @see FuncAsRunnable
- * @see RunnableAsFunc
  * @since 0.2
  */
-public final class CallableAsFunc<X, Y> implements Func<X, Y> {
+public final class ReplacedText implements Text {
+
+    /**
+     * The text.
+     */
+    private final Text origin;
 
     /**
-     * The callable.
+     * The old char.
      */
-    private final Callable<Y> callable;
+    private final String needle;
+
+    /**
+     * The new char.
+     */
+    private final String replacement;
 
     /**
      * Ctor.
-     * @param clbl The callable
+     * @param text The text
+     * @param find The find one
+     * @param replace The replace one
      */
-    public CallableAsFunc(final Callable<Y> clbl) {
-        this.callable = clbl;
+    public ReplacedText(final Text text, final String find, final String
+        replace) {
+        this.origin = text;
+        this.needle = find;
+        this.replacement = replace;
     }
 
     @Override
-    public Y apply(final X input) throws Exception {
-        return this.callable.call();
+    public String asString() throws IOException {
+        return this.origin.asString().replace(this.needle, this.replacement);
     }
 }
+


Test patch:
diff --git a/src/test/java/org/cactoos/func/ConstFuncTest.java b/src/test/java/org/cactoos/func/ConstFuncTest.java
deleted file mode 100644
index 53823302..00000000
--- a/src/test/java/org/cactoos/func/ConstFuncTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.FuncApplies;
-import org.hamcrest.MatcherAssert;
-import org.junit.Test;
-
-/**
- * Test case for {@link ConstFunc}.
- *
- * @author Yegor Bugayenko (yegor256@gmail.com)
- * @version $Id$
- * @since 0.2
- * @checkstyle JavadocMethodCheck (500 lines)
- */
-public final class ConstFuncTest {
-
-    @Test
-    public void returnsConstant() {
-        MatcherAssert.assertThat(
-            "Can't return a constant",
-            new ConstFunc<>(1),
-            new FuncApplies<>(-1, 1)
-        );
-    }
-
-}
diff --git a/src/test/java/org/cactoos/func/FuncAsCallableTest.java b/src/test/java/org/cactoos/func/FuncAsCallableTest.java
deleted file mode 100644
index 23807c35..00000000
--- a/src/test/java/org/cactoos/func/FuncAsCallableTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
-import org.junit.Test;
-
-/**
- * Test case for {@link FuncAsCallable}.
- *
- * @author Yegor Bugayenko (yegor256@gmail.com)
- * @version $Id$
- * @since 0.2
- * @checkstyle JavadocMethodCheck (500 lines)
- */
-public final class FuncAsCallableTest {
-
-    @Test
-    public void convertsFuncIntoCallable() throws Exception {
-        MatcherAssert.assertThat(
-            new FuncAsCallable<>(
-                input -> 1
-            ).call(),
-            Matchers.equalTo(1)
-        );
-    }
-
-}
diff --git a/src/test/java/org/cactoos/func/FuncWithCallbackTest.java b/src/test/java/org/cactoos/func/FuncWithCallbackTest.java
index 44f4c89f..e4103ed4 100644
--- a/src/test/java/org/cactoos/func/FuncWithCallbackTest.java
+++ b/src/test/java/org/cactoos/func/FuncWithCallbackTest.java
@@ -24,7 +24,7 @@
 package org.cactoos.func;
 
 import java.io.IOException;
-import org.cactoos.FuncApplies;
+import org.cactoos.Func;
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
 import org.junit.Test;
@@ -44,10 +44,10 @@ public final class FuncWithCallbackTest {
         MatcherAssert.assertThat(
             "Can't use the main function if no exception",
             new FuncWithCallback<>(
-                input -> "It's success",
+                (Func<Integer, String>) input -> "It's success",
                 ex -> "In case of failure..."
-            ),
-            new FuncApplies<>(1, Matchers.containsString("success"))
+            ).apply(1),
+            Matchers.containsString("success")
         );
     }
 
@@ -56,12 +56,12 @@ public final class FuncWithCallbackTest {
         MatcherAssert.assertThat(
             "Can't use the callback in case of exception",
             new FuncWithCallback<>(
-                input -> {
+                (Func<Integer, String>) input -> {
                     throw new IOException("Failure");
                 },
                 ex -> "Never mind"
-            ),
-            new FuncApplies<>(1, Matchers.containsString("Never"))
+            ).apply(1),
+            Matchers.containsString("Never")
         );
     }
 
diff --git a/src/test/java/org/cactoos/func/UncheckedFuncTest.java b/src/test/java/org/cactoos/func/UncheckedFuncTest.java
deleted file mode 100644
index 1ec4ee5f..00000000
--- a/src/test/java/org/cactoos/func/UncheckedFuncTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.junit.Test;
-
-/**
- * Test case for {@link UncheckedFunc}.
- *
- * @author Yegor Bugayenko (yegor256@gmail.com)
- * @version $Id$
- * @since 0.2
- * @checkstyle JavadocMethodCheck (500 lines)
- */
-public final class UncheckedFuncTest {
-
-    @Test(expected = RuntimeException.class)
-    public void rethrowsCheckedToUncheckedException() {
-        new UncheckedFunc<>(
-            (Func<Integer, String>) i -> {
-                throw new IOException("intended");
-            }
-        ).apply(1);
-    }
-
-}
diff --git a/src/test/java/org/cactoos/io/ResourceAsInputTest.java b/src/test/java/org/cactoos/io/ResourceAsInputTest.java
index 20e2e947..d2b9e10f 100644
--- a/src/test/java/org/cactoos/io/ResourceAsInputTest.java
+++ b/src/test/java/org/cactoos/io/ResourceAsInputTest.java
@@ -60,5 +60,4 @@ public final class ResourceAsInputTest {
             )
         );
     }
-
 }
diff --git a/src/test/java/org/cactoos/list/AllOfTest.java b/src/test/java/org/cactoos/list/AllOfTest.java
index 92963287..a440ace2 100644
--- a/src/test/java/org/cactoos/list/AllOfTest.java
+++ b/src/test/java/org/cactoos/list/AllOfTest.java
@@ -26,8 +26,8 @@ package org.cactoos.list;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
+import org.cactoos.Func;
 import org.cactoos.ScalarHasValue;
-import org.cactoos.func.AlwaysTrueFunc;
 import org.cactoos.func.FuncAsMatcher;
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
@@ -50,7 +50,7 @@ public final class AllOfTest {
             new AllOf(
                 new TransformedIterable<>(
                     new ArrayAsIterable<>("hello", "world"),
-                    list::add
+                    (Func.Quiet<String>) list::add
                 )
             ),
             new ScalarHasValue<>(
@@ -70,9 +70,9 @@ public final class AllOfTest {
         MatcherAssert.assertThat(
             "Can't iterate a list",
             new AllOf(
-                new IterableAsBooleans<String>(
+                new IterableAsBooleans<>(
                     Collections.emptyList(),
-                    new AlwaysTrueFunc<>(list::add)
+                    (Func.Quiet<String>) list::add
                 )
             ),
             new ScalarHasValue<>(
diff --git a/src/test/java/org/cactoos/func/FuncAsRunnableTest.java b/src/test/java/org/cactoos/text/ReplacedTextTest.java
similarity index 65%
rename from src/test/java/org/cactoos/func/FuncAsRunnableTest.java
rename to src/test/java/org/cactoos/text/ReplacedTextTest.java
index 8d3571f9..34536029 100644
--- a/src/test/java/org/cactoos/func/FuncAsRunnableTest.java
+++ b/src/test/java/org/cactoos/text/ReplacedTextTest.java
@@ -21,40 +21,44 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-package org.cactoos.func;
+package org.cactoos.text;
 
-import java.util.concurrent.atomic.AtomicBoolean;
+import org.cactoos.TextHasString;
 import org.hamcrest.MatcherAssert;
 import org.junit.Test;
 
 /**
- * Test case for {@link FuncAsRunnable}.
+ * Test case for {@link ReplacedText}.
  *
- * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @author Mehmet Yildirim (memoyil@gmail.com)
  * @version $Id$
  * @since 0.2
  * @checkstyle JavadocMethodCheck (500 lines)
  */
-public final class FuncAsRunnableTest {
+public final class ReplacedTextTest {
 
     @Test
-    public void convertsFuncIntoRunnable() throws Exception {
-        final AtomicBoolean done = new AtomicBoolean();
+    public void replaceText() {
         MatcherAssert.assertThat(
-            "Can't execute Runnable",
-            new FuncAsRunnable(
-                input -> {
-                    done.set(true);
-                    return 1;
-                }
+            "Can't replace a text",
+            new ReplacedText(
+                new StringAsText("Hello!"),
+                "ello", "i"
             ),
-            new FuncAsMatcher<Runnable>(
-                input -> {
-                    input.run();
-                    return done.get();
-                }
-            )
+            new TextHasString("Hi!")
         );
     }
 
+    @Test
+    public void notReplaceTextWhenSubstringNotFound() {
+        final String text = "HelloAgain!";
+        MatcherAssert.assertThat(
+            "Replace a text abnormally",
+            new ReplacedText(
+                new StringAsText(text),
+                "xyz", "i"
+            ),
+            new TextHasString(text)
+        );
+    }
 }