Remove methods that will be new in 3.11 but which are now in the

function package.
This commit is contained in:
Gary Gregory 2020-06-24 10:41:19 -04:00
parent 1dddec8ba8
commit c56c77ed95
2 changed files with 0 additions and 225 deletions

View File

@ -313,42 +313,6 @@ public static <O, T extends Throwable> void accept(final FailableConsumer<O, T>
run(() -> consumer.accept(object));
}
/**
* 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}.
*
@ -380,21 +344,6 @@ public static <I, O, T extends Throwable> O apply(final FailableFunction<I, O, T
return get(() -> function.apply(input));
}
/**
* 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}.
*
@ -536,70 +485,6 @@ public static <O, T extends Throwable> O get(final FailableSupplier<O, T> suppli
}
}
/**
* 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

View File

@ -510,19 +510,6 @@ public void testApplyBiFunction() {
assertEquals(0, i.intValue());
}
@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();
@ -736,103 +723,6 @@ public void testFunction() {
assertEquals(0, function.apply(null).intValue());
}
@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;