aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/apache/commons/lang3/Functions.java
diff options
context:
space:
mode:
authorGary Gregory <garydgregory@gmail.com>2020-06-17 09:30:21 -0400
committerGary Gregory <garydgregory@gmail.com>2020-06-17 09:30:21 -0400
commit36111ba5829bdd4249c7418c1aec17c149ef86a3 (patch)
treed007c75e101be76fa1a126882f4623c593d186ee /src/main/java/org/apache/commons/lang3/Functions.java
parent8a2d7afd9f1be1c6cc6b5f3102b6659846fad874 (diff)
downloadapache-commons-lang-36111ba5829bdd4249c7418c1aec17c149ef86a3.tar.gz
[LANG-1568] More failable functional interfaces to match JRE functional
interfaces.
Diffstat (limited to 'src/main/java/org/apache/commons/lang3/Functions.java')
-rw-r--r--src/main/java/org/apache/commons/lang3/Functions.java76
1 files changed, 68 insertions, 8 deletions
diff --git a/src/main/java/org/apache/commons/lang3/Functions.java b/src/main/java/org/apache/commons/lang3/Functions.java
index 0eeef4473..16e7a0c10 100644
--- a/src/main/java/org/apache/commons/lang3/Functions.java
+++ b/src/main/java/org/apache/commons/lang3/Functions.java
@@ -30,6 +30,7 @@ import java.util.function.Consumer;
import java.util.function.DoubleBinaryOperator;
import java.util.function.DoubleConsumer;
import java.util.function.DoubleFunction;
+import java.util.function.DoublePredicate;
import java.util.function.DoubleSupplier;
import java.util.function.DoubleToIntFunction;
import java.util.function.DoubleToLongFunction;
@@ -37,12 +38,14 @@ import java.util.function.Function;
import java.util.function.IntBinaryOperator;
import java.util.function.IntConsumer;
import java.util.function.IntFunction;
+import java.util.function.IntPredicate;
import java.util.function.IntSupplier;
import java.util.function.IntToDoubleFunction;
import java.util.function.IntToLongFunction;
import java.util.function.LongBinaryOperator;
import java.util.function.LongConsumer;
import java.util.function.LongFunction;
+import java.util.function.LongPredicate;
import java.util.function.LongSupplier;
import java.util.function.LongToDoubleFunction;
import java.util.function.LongToIntFunction;
@@ -111,7 +114,7 @@ public class Functions {
*
* @param object1 the first parameter for the consumable to accept
* @param object2 the second parameter for the consumable to accept
- * @throws T if the consumer fails
+ * @throws T Thrown when the consumer fails.
*/
void accept(O1 object1, O2 object2) throws T;
}
@@ -208,7 +211,7 @@ public class Functions {
* Accepts the consumer.
*
* @param object the parameter for the consumable to accept
- * @throws T if the consumer fails
+ * @throws T Thrown when the consumer fails.
*/
void accept(O object) throws T;
}
@@ -246,7 +249,7 @@ public class Functions {
* Accepts the consumer.
*
* @param value the parameter for the consumable to accept
- * @throws T if the consumer fails
+ * @throws T Thrown when the consumer fails.
*/
void accept(double value) throws T;
}
@@ -271,6 +274,25 @@ public class Functions {
}
/**
+ * A functional interface like {@link DoublePredicate} that declares a {@code Throwable}.
+ *
+ * @param <T> Thrown exception.
+ * @since 3.11
+ */
+ @FunctionalInterface
+ public interface FailableDoublePredicate<T extends Throwable> {
+
+ /**
+ * Tests the predicate.
+ *
+ * @param value the parameter for the predicate to accept.
+ * @return {@code true} if the input argument matches the predicate, {@code false} otherwise.
+ * @throws T Thrown when the consumer fails.
+ */
+ boolean test(double value) throws T;
+ }
+
+ /**
* A functional interface like {@link DoubleSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
@@ -379,7 +401,7 @@ public class Functions {
* Accepts the consumer.
*
* @param value the parameter for the consumable to accept
- * @throws T if the consumer fails
+ * @throws T Thrown when the consumer fails.
*/
void accept(int value) throws T;
}
@@ -404,6 +426,25 @@ public class Functions {
}
/**
+ * A functional interface like {@link IntPredicate} that declares a {@code Throwable}.
+ *
+ * @param <T> Thrown exception.
+ * @since 3.11
+ */
+ @FunctionalInterface
+ public interface FailableIntPredicate<T extends Throwable> {
+
+ /**
+ * Tests the predicate.
+ *
+ * @param value the parameter for the predicate to accept.
+ * @return {@code true} if the input argument matches the predicate, {@code false} otherwise.
+ * @throws T Thrown when the consumer fails.
+ */
+ boolean test(int value) throws T;
+ }
+
+ /**
* A functional interface like {@link IntSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
@@ -492,7 +533,7 @@ public class Functions {
* Accepts the consumer.
*
* @param object the parameter for the consumable to accept
- * @throws T if the consumer fails
+ * @throws T Thrown when the consumer fails.
*/
void accept(long object) throws T;
}
@@ -517,6 +558,25 @@ public class Functions {
}
/**
+ * A functional interface like {@link LongPredicate} that declares a {@code Throwable}.
+ *
+ * @param <T> Thrown exception.
+ * @since 3.11
+ */
+ @FunctionalInterface
+ public interface FailableLongPredicate<T extends Throwable> {
+
+ /**
+ * Tests the predicate.
+ *
+ * @param value the parameter for the predicate to accept.
+ * @return {@code true} if the input argument matches the predicate, {@code false} otherwise.
+ * @throws T Thrown when the consumer fails.
+ */
+ boolean test(long value) throws T;
+ }
+
+ /**
* A functional interface like {@link LongSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
@@ -587,7 +647,7 @@ public class Functions {
*
* @param object the object parameter for the consumable to accept.
* @param value the double parameter for the consumable to accept.
- * @throws T if the consumer fails
+ * @throws T Thrown when the consumer fails.
*/
void accept(O object, double value) throws T;
}
@@ -607,7 +667,7 @@ public class Functions {
*
* @param object the object parameter for the consumable to accept.
* @param value the int parameter for the consumable to accept.
- * @throws T if the consumer fails
+ * @throws T Thrown when the consumer fails.
*/
void accept(O object, int value) throws T;
}
@@ -627,7 +687,7 @@ public class Functions {
*
* @param object the object parameter for the consumable to accept.
* @param value the long parameter for the consumable to accept.
- * @throws T if the consumer fails
+ * @throws T Thrown when the consumer fails.
*/
void accept(O object, long value) throws T;
}