diff --git a/src/main/java/org/apache/commons/lang3/Functions.java b/src/main/java/org/apache/commons/lang3/Functions.java index b4cd1f631..3a9dbf3d1 100644 --- a/src/main/java/org/apache/commons/lang3/Functions.java +++ b/src/main/java/org/apache/commons/lang3/Functions.java @@ -54,6 +54,7 @@ * Lambda expressions is met better than the second version. */ public class Functions { + @FunctionalInterface public interface FailableRunnable { /** @@ -62,6 +63,7 @@ public interface FailableRunnable { */ void run() throws T; } + @FunctionalInterface public interface FailableCallable { /** @@ -71,6 +73,7 @@ public interface FailableCallable { */ O call() throws T; } + @FunctionalInterface public interface FailableConsumer { /** @@ -80,6 +83,7 @@ public interface FailableConsumer { */ void accept(O pObject) throws T; } + @FunctionalInterface public interface FailableBiConsumer { /** @@ -90,6 +94,7 @@ public interface FailableBiConsumer { */ void accept(O1 pObject1, O2 pObject2) throws T; } + @FunctionalInterface public interface FailableFunction { /** @@ -100,6 +105,7 @@ public interface FailableFunction { */ O apply(I pInput) throws T; } + @FunctionalInterface public interface FailableBiFunction { /** @@ -111,6 +117,7 @@ public interface FailableBiFunction { */ O apply(I1 pInput1, I2 pInput2) throws T; } + @FunctionalInterface public interface FailablePredicate { /** @@ -121,6 +128,7 @@ public interface FailablePredicate { */ boolean test(O pObject) throws T; } + @FunctionalInterface public interface FailableBiPredicate { /** @@ -132,6 +140,7 @@ public interface FailableBiPredicate { */ boolean test(O1 pObject1, O2 pObject2) throws T; } + @FunctionalInterface public interface FailableSupplier { /** @@ -536,23 +545,22 @@ public static void tryWithResources(FailableRunnable pActio } /** - * Rethrow a {@link Throwable} as an unchecked exception. + * Rethrows a {@link Throwable} as an unchecked exception. * @param pThrowable The throwable to rethrow * @return Never returns anything, this method never terminates normally */ public static RuntimeException rethrow(Throwable pThrowable) { if (pThrowable == null) { throw new NullPointerException("The Throwable must not be null."); + } + if (pThrowable instanceof RuntimeException) { + throw (RuntimeException) pThrowable; + } else if (pThrowable instanceof Error) { + throw (Error) pThrowable; + } else if (pThrowable instanceof IOException) { + throw new UncheckedIOException((IOException) pThrowable); } else { - if (pThrowable instanceof RuntimeException) { - throw (RuntimeException) pThrowable; - } else if (pThrowable instanceof Error) { - throw (Error) pThrowable; - } else if (pThrowable instanceof IOException) { - throw new UncheckedIOException((IOException) pThrowable); - } else { - throw new UndeclaredThrowableException(pThrowable); - } + throw new UndeclaredThrowableException(pThrowable); } } }