Skip to content

Commit

Permalink
Merge branch 'master' into sync-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
g4s8 committed Jul 19, 2017
2 parents 3cf9261 + d46fb6f commit 2956d32
Show file tree
Hide file tree
Showing 32 changed files with 487 additions and 694 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/func/And.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public final class And implements Scalar<Boolean> {
*/
@SafeVarargs
public <X> And(final Proc<X> proc, final X... src) {
this(new ProcAsFunc<>(proc, true), src);
this(new FuncOf<>(proc, true), src);
}

/**
Expand All @@ -74,7 +74,7 @@ public <X> And(final Func<X, Boolean> func, final X... src) {
* @param <X> Type of items in the iterable
*/
public <X> And(final Iterable<X> src, final Proc<X> proc) {
this(src, new ProcAsFunc<>(proc, true));
this(src, new FuncOf<>(proc, true));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/func/AsyncFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public final class AsyncFunc<X, Y> implements Func<X, Future<Y>> {
* @param proc The proc
*/
public AsyncFunc(final Proc<X> proc) {
this(new ProcAsFunc<>(proc));
this(new FuncOf<>(proc));
}

/**
Expand All @@ -81,7 +81,7 @@ public AsyncFunc(final Func<X, Y> fnc) {
* @param fct Factory
*/
public AsyncFunc(final Proc<X> proc, final ThreadFactory fct) {
this(new ProcAsFunc<>(proc), fct);
this(new FuncOf<>(proc), fct);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.util.concurrent.Callable;
import org.cactoos.Func;
import org.cactoos.Proc;

/**
* Func as {@link Callable}.
Expand All @@ -41,26 +42,60 @@
*
* @author Yegor Bugayenko ([email protected])
* @version $Id$
* @param <T> Type of input
* @since 0.2
* @param <X> Type of input
* @param <T> Type of output
* @since 0.12
*/
public final class FuncAsCallable<T> implements Callable<T> {
public final class CallableOf<X, T> implements Callable<T> {

/**
* Original func.
*/
private final Func<?, T> func;
private final Func<X, T> func;

/**
* The input.
*/
private final X input;

/**
* Ctor.
* @param runnable Encapsulated proc
* @since 0.12
*/
public CallableOf(final Runnable runnable) {
this(new FuncOf<>(runnable));
}

/**
* Ctor.
* @param proc Encapsulated proc
* @since 0.12
*/
public CallableOf(final Proc<X> proc) {
this(new FuncOf<>(proc));
}

/**
* Ctor.
* @param fnc Encapsulated func
*/
public CallableOf(final Func<X, T> fnc) {
this(fnc, null);
}

/**
* Ctor.
* @param fnc Encapsulated func
* @param ipt Input
*/
public FuncAsCallable(final Func<?, T> fnc) {
public CallableOf(final Func<X, T> fnc, final X ipt) {
this.func = fnc;
this.input = ipt;
}

@Override
public T call() throws Exception {
return this.func.apply(null);
return this.func.apply(this.input);
}
}
71 changes: 0 additions & 71 deletions src/main/java/org/cactoos/func/CallableWithFallback.java

This file was deleted.

27 changes: 12 additions & 15 deletions src/main/java/org/cactoos/func/ChainedFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,24 @@ public final class ChainedFunc<X, Y, Z> implements Func<X, Z> {

/**
* Ctor.
* @param before Before function
* @param funcs Functions
* @param after After function
* @param bfr Before function
* @param list Functions
* @param atr After function
*/
public ChainedFunc(
final Func<X, Y> before,
final Iterable<Func<Y, Y>> funcs,
final Func<Y, Z> after
) {
this.before = before;
this.funcs = funcs;
this.after = after;
public ChainedFunc(final Func<X, Y> bfr, final Iterable<Func<Y, Y>> list,
final Func<Y, Z> atr) {
this.before = bfr;
this.funcs = list;
this.after = atr;
}

/**
* Ctor.
* @param before Before function
* @param after After function
* @param bfr Before function
* @param atr After function
*/
public ChainedFunc(final Func<X, Y> before, final Func<Y, Z> after) {
this(before, Collections.emptyList(), after);
public ChainedFunc(final Func<X, Y> bfr, final Func<Y, Z> atr) {
this(bfr, Collections.emptyList(), atr);
}

@Override
Expand Down
59 changes: 0 additions & 59 deletions src/main/java/org/cactoos/func/ConstFunc.java

This file was deleted.

58 changes: 0 additions & 58 deletions src/main/java/org/cactoos/func/FuncAsProc.java

This file was deleted.

Loading

0 comments on commit 2956d32

Please sign in to comment.