This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push: new c56c77e Remove methods that will be new in 3.11 but which are now in the function package. c56c77e is described below commit c56c77ed9502d079b3e885a65bc4a4cf666ac8ee Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed Jun 24 10:41:19 2020 -0400 Remove methods that will be new in 3.11 but which are now in the function package. --- .../java/org/apache/commons/lang3/Functions.java | 115 --------------------- .../org/apache/commons/lang3/FunctionsTest.java | 110 -------------------- 2 files changed, 225 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/Functions.java b/src/main/java/org/apache/commons/lang3/Functions.java index 4cf9d55..a8cba22 100644 --- a/src/main/java/org/apache/commons/lang3/Functions.java +++ b/src/main/java/org/apache/commons/lang3/Functions.java @@ -314,42 +314,6 @@ public class Functions { } /** - * Consumes a consumer and rethrows any exception as a {@link RuntimeException}. - * - * @param consumer the consumer to consume - * @param value the value to consume by {@code consumer} - * @param <T> the type of checked exception the consumer may throw - * @since 3.11 - */ - public static <T extends Throwable> void accept(final FailableDoubleConsumer<T> consumer, final double value) { - run(() -> consumer.accept(value)); - } - - /** - * Consumes a consumer and rethrows any exception as a {@link RuntimeException}. - * - * @param consumer the consumer to consume - * @param value the value to consume by {@code consumer} - * @param <T> the type of checked exception the consumer may throw - * @since 3.11 - */ - public static <T extends Throwable> void accept(final FailableIntConsumer<T> consumer, final int value) { - run(() -> consumer.accept(value)); - } - - /** - * Consumes a consumer and rethrows any exception as a {@link RuntimeException}. - * - * @param consumer the consumer to consume - * @param value the value to consume by {@code consumer} - * @param <T> the type of checked exception the consumer may throw - * @since 3.11 - */ - public static <T extends Throwable> void accept(final FailableLongConsumer<T> consumer, final long value) { - run(() -> consumer.accept(value)); - } - - /** * Applies a function and rethrows any exception as a {@link RuntimeException}. * * @param function the function to apply @@ -381,21 +345,6 @@ public class Functions { } /** - * Applies a function and rethrows any exception as a {@link RuntimeException}. - * - * @param function the function to apply - * @param left the first input to apply {@code function} on - * @param right the second input to apply {@code function} on - * @param <T> the type of checked exception the function may throw - * @return the value returned from the function - * @since 3.11 - */ - public static <T extends Throwable> double applyAsDouble(final FailableDoubleBinaryOperator<T> function, - final double left, final double right) { - return getAsDouble(() -> function.applyAsDouble(left, right)); - } - - /** * Converts the given {@link FailableBiConsumer} into a standard {@link BiConsumer}. * * @param <O1> the type of the first argument of the consumers @@ -537,70 +486,6 @@ public class Functions { } /** - * Invokes a boolean supplier, and returns the result. - * - * @param supplier The boolean supplier to invoke. - * @param <T> The type of checked exception, which the supplier can throw. - * @return The boolean, which has been created by the supplier - * @since 3.11 - */ - public static <T extends Throwable> boolean getAsBoolean(final FailableBooleanSupplier<T> supplier) { - try { - return supplier.getAsBoolean(); - } catch (final Throwable t) { - throw rethrow(t); - } - } - - /** - * Invokes a double supplier, and returns the result. - * - * @param supplier The double supplier to invoke. - * @param <T> The type of checked exception, which the supplier can throw. - * @return The boolean, which has been created by the supplier - * @since 3.11 - */ - public static <T extends Throwable> double getAsDouble(final FailableDoubleSupplier<T> supplier) { - try { - return supplier.getAsDouble(); - } catch (final Throwable t) { - throw rethrow(t); - } - } - - /** - * Invokes an int supplier, and returns the result. - * - * @param supplier The int supplier to invoke. - * @param <T> The type of checked exception, which the supplier can throw. - * @return The boolean, which has been created by the supplier - * @since 3.11 - */ - public static <T extends Throwable> int getAsInt(final FailableIntSupplier<T> supplier) { - try { - return supplier.getAsInt(); - } catch (final Throwable t) { - throw rethrow(t); - } - } - - /** - * Invokes a long supplier, and returns the result. - * - * @param supplier The long supplier to invoke. - * @param <T> The type of checked exception, which the supplier can throw. - * @return The boolean, which has been created by the supplier - * @since 3.11 - */ - public static <T extends Throwable> long getAsLong(final FailableLongSupplier<T> supplier) { - try { - return supplier.getAsLong(); - } catch (final Throwable t) { - throw rethrow(t); - } - } - - /** * <p> * Rethrows a {@link Throwable} as an unchecked exception. If the argument is already unchecked, namely a * {@code RuntimeException} or {@code Error} then the argument will be rethrown without modification. If the diff --git a/src/test/java/org/apache/commons/lang3/FunctionsTest.java b/src/test/java/org/apache/commons/lang3/FunctionsTest.java index 3b2aa0e..3e58fd7 100644 --- a/src/test/java/org/apache/commons/lang3/FunctionsTest.java +++ b/src/test/java/org/apache/commons/lang3/FunctionsTest.java @@ -511,19 +511,6 @@ public class FunctionsTest { } @Test - public void testApplyDoubleBinaryOperator() { - final IllegalStateException ise = new IllegalStateException(); - final Testable<?, Double> testable = new Testable<>(ise); - Throwable e = assertThrows(IllegalStateException.class, - () -> Functions.applyAsDouble(testable::testDoubleDouble, 1d, 2d)); - assertSame(ise, e); - - final Testable<?, Double> testable2 = new Testable<>(null); - final double i = Functions.applyAsDouble(testable2::testDoubleDouble, 1d, 2d); - assertEquals(3d, i); - } - - @Test public void testApplyFunction() { final IllegalStateException ise = new IllegalStateException(); final Testable<?, ?> testable = new Testable<>(ise); @@ -737,103 +724,6 @@ public class FunctionsTest { } @Test - public void testGetAsBooleanSupplier() { - final IllegalStateException ise = new IllegalStateException(); - final Testable<?, ?> testable = new Testable<>(ise); - Throwable e = assertThrows(IllegalStateException.class, - () -> Functions.getAsBoolean(testable::testAsBooleanPrimitive)); - assertSame(ise, e); - - final Error error = new OutOfMemoryError(); - testable.setThrowable(error); - e = assertThrows(OutOfMemoryError.class, () -> Functions.getAsBoolean(testable::testAsBooleanPrimitive)); - assertSame(error, e); - - final IOException ioe = new IOException("Unknown I/O error"); - testable.setThrowable(ioe); - e = assertThrows(UncheckedIOException.class, () -> Functions.getAsBoolean(testable::testAsBooleanPrimitive)); - final Throwable t = e.getCause(); - assertNotNull(t); - assertSame(ioe, t); - - testable.setThrowable(null); - assertFalse(Functions.getAsBoolean(testable::testAsBooleanPrimitive)); - } - - @Test - public void testGetAsDoubleSupplier() { - final IllegalStateException ise = new IllegalStateException(); - final Testable<?, ?> testable = new Testable<>(ise); - Throwable e = assertThrows(IllegalStateException.class, - () -> Functions.getAsDouble(testable::testAsDoublePrimitive)); - assertSame(ise, e); - - final Error error = new OutOfMemoryError(); - testable.setThrowable(error); - e = assertThrows(OutOfMemoryError.class, () -> Functions.getAsDouble(testable::testAsDoublePrimitive)); - assertSame(error, e); - - final IOException ioe = new IOException("Unknown I/O error"); - testable.setThrowable(ioe); - e = assertThrows(UncheckedIOException.class, () -> Functions.getAsDouble(testable::testAsDoublePrimitive)); - final Throwable t = e.getCause(); - assertNotNull(t); - assertSame(ioe, t); - - testable.setThrowable(null); - assertEquals(0, Functions.getAsDouble(testable::testAsDoublePrimitive)); - } - - @Test - public void testGetAsIntSupplier() { - final IllegalStateException ise = new IllegalStateException(); - final Testable<?, ?> testable = new Testable<>(ise); - Throwable e = assertThrows(IllegalStateException.class, () -> Functions.getAsInt(testable::testAsIntPrimitive)); - assertSame(ise, e); - - final Error error = new OutOfMemoryError(); - testable.setThrowable(error); - e = assertThrows(OutOfMemoryError.class, () -> Functions.getAsInt(testable::testAsIntPrimitive)); - assertSame(error, e); - - final IOException ioe = new IOException("Unknown I/O error"); - testable.setThrowable(ioe); - e = assertThrows(UncheckedIOException.class, () -> Functions.getAsInt(testable::testAsIntPrimitive)); - final Throwable t = e.getCause(); - assertNotNull(t); - assertSame(ioe, t); - - testable.setThrowable(null); - final int i = Functions.getAsInt(testable::testAsInteger); - assertEquals(0, i); - } - - @Test - public void testGetAsLongSupplier() { - final IllegalStateException ise = new IllegalStateException(); - final Testable<?, ?> testable = new Testable<>(ise); - Throwable e = assertThrows(IllegalStateException.class, - () -> Functions.getAsLong(testable::testAsLongPrimitive)); - assertSame(ise, e); - - final Error error = new OutOfMemoryError(); - testable.setThrowable(error); - e = assertThrows(OutOfMemoryError.class, () -> Functions.getAsLong(testable::testAsLongPrimitive)); - assertSame(error, e); - - final IOException ioe = new IOException("Unknown I/O error"); - testable.setThrowable(ioe); - e = assertThrows(UncheckedIOException.class, () -> Functions.getAsLong(testable::testAsLongPrimitive)); - final Throwable t = e.getCause(); - assertNotNull(t); - assertSame(ioe, t); - - testable.setThrowable(null); - final long i = Functions.getAsLong(testable::testAsLongPrimitive); - assertEquals(0, i); - } - - @Test public void testGetFromSupplier() { FailureOnOddInvocations.invocations = 0; final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class,