-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Grzegorz Piwowarek
committed
Nov 27, 2015
1 parent
1474313
commit 8151ca6
Showing
7 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package touk.pl.function; | ||
|
||
import java.util.Objects; | ||
|
||
@FunctionalInterface | ||
public interface ThrowingConsumer<T, E extends Exception> { | ||
void accept(T t) throws E; | ||
|
||
default ThrowingConsumer<T, E> andThenConsume(final ThrowingConsumer<? super T, E> after) { | ||
Objects.requireNonNull(after); | ||
|
||
return t -> { | ||
accept(t); | ||
after.accept(t); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package touk.pl.function; | ||
|
||
@FunctionalInterface | ||
public interface ThrowingRunnable<E extends Exception> { | ||
void run() throws E; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package touk.pl.function; | ||
|
||
@FunctionalInterface | ||
public interface ThrowingSupplier<T, E extends Exception> { | ||
T get() throws E; | ||
|
||
static <T, E extends Exception> ThrowingSupplier<T, E> empty() { | ||
return () -> null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package touk.pl.function; | ||
|
||
@FunctionalInterface | ||
public interface ThrowingUnaryOperator<T, E extends Exception> extends ThrowingFunction<T, T, E> { | ||
|
||
static <T, E extends Exception> ThrowingUnaryOperator<T, E> identity() { | ||
return t -> t; | ||
} | ||
|
||
default ThrowingUnaryOperator<T, E> applyBefore(final ThrowingUnaryOperator<T, E> operator) { | ||
return t -> operator.apply(apply(t)); | ||
} | ||
|
||
default ThrowingUnaryOperator<T, E> applyAfter(final ThrowingUnaryOperator<T, E> operator) { | ||
return t -> apply(operator.apply(t)); | ||
} | ||
} |