Skip to content

Commit

Permalink
#274: more ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 20, 2017
1 parent d46fb6f commit 0130b25
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/func/FuncOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public FuncOf(final Proc<X> proc, final Y result) {
* Ctor.
* @param fnc Func
*/
public FuncOf(final Func<X, Y> fnc) {
private FuncOf(final Func<X, Y> fnc) {
this.func = fnc;
}

Expand Down
33 changes: 33 additions & 0 deletions src/main/java/org/cactoos/func/FuncWithFallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,39 @@ public FuncWithFallback(final Func<X, Y> fnc,
this(fnc, fbk, input -> input);
}

/**
* Ctor.
* @param proc The proc
* @param fbk The fallback
* @since 0.12
*/
public FuncWithFallback(final Proc<X> proc,
final Func<Throwable, Y> fbk) {
this(new FuncOf<>(proc), fbk);
}

/**
* Ctor.
* @param proc The proc
* @param fbk The fallback
* @since 0.12
*/
public FuncWithFallback(final Proc<X> proc,
final Proc<Throwable> fbk) {
this(new FuncOf<>(proc), new FuncOf<>(fbk));
}

/**
* Ctor.
* @param proc The proc
* @param fbk The fallback
* @since 0.12
*/
public FuncWithFallback(final Func<X, Y> proc,
final Proc<Throwable> fbk) {
this(proc, new FuncOf<>(fbk));
}

/**
* Ctor.
* @param fnc The func
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/func/ProcOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ProcOf(final Func<X, ?> fnc) {
* Ctor.
* @param prc The proc
*/
public ProcOf(final Proc<X> prc) {
private ProcOf(final Proc<X> prc) {
this.proc = prc;
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/cactoos/func/FuncWithFallbackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.io.IOException;
import org.cactoos.FuncApplies;
import org.cactoos.Proc;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
Expand Down Expand Up @@ -56,7 +57,7 @@ public void usesCallback() throws Exception {
MatcherAssert.assertThat(
"Can't use the callback in case of exception",
new FuncWithFallback<>(
input -> {
(Proc<Integer>) input -> {
throw new IOException("Failure");
},
ex -> "Never mind"
Expand Down

0 comments on commit 0130b25

Please sign in to comment.