-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from aNNiMON/safe-functions
Safe functions
- Loading branch information
Showing
11 changed files
with
345 additions
and
6 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
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
20 changes: 20 additions & 0 deletions
20
stream/src/main/java/com/annimon/stream/function/ThrowableConsumer.java
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,20 @@ | ||
package com.annimon.stream.function; | ||
|
||
/** | ||
* Represents an operation on input argument and can throw an exception. | ||
* | ||
* @param <T> the type of the input to the operation | ||
* @param <E> the type of the exception | ||
* @see Consumer | ||
*/ | ||
@FunctionalInterface | ||
public interface ThrowableConsumer<T, E extends Throwable> { | ||
|
||
/** | ||
* Performs operation on argument. | ||
* | ||
* @param value the input argument | ||
* @throws E an exception | ||
*/ | ||
void accept(T value) throws E; | ||
} |
20 changes: 20 additions & 0 deletions
20
stream/src/main/java/com/annimon/stream/function/ThrowablePredicate.java
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,20 @@ | ||
package com.annimon.stream.function; | ||
|
||
/** | ||
* Represents a predicate, i.e. function with boolean type result which can throw an exception. | ||
* | ||
* @param <T> the type of the input to the function | ||
* @param <E> the type of the exception | ||
*/ | ||
@FunctionalInterface | ||
public interface ThrowablePredicate<T, E extends Throwable> { | ||
|
||
/** | ||
* Tests the value for satisfying predicate. | ||
* | ||
* @param value the value to be tests | ||
* @return {@code true} if the value matches the predicate, otherwise {@code false} | ||
* @throws E an exception | ||
*/ | ||
boolean test(T value) 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
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
Oops, something went wrong.