Add IOBiConsumer#asBiConsumer()
MODIFY
src/main/java/org/apache/commons/io/function/IOBiConsumer.java
src/main/java/org/apache/commons/io/function/IOBiConsumer.java
package org.apache.commons.io.function;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.util.Objects;
import java.util.function.BiConsumer;
after.accept(t, u);
};
}
+
+ /**
+ * Converts this instance to a {@link BiConsumer} that throws {@link UncheckedIOException} instead of
+ * {@link IOException}.
+ *
+ * @return an unchecked BiConsumer.
+ * @since 2.12.0
+ */
+ default BiConsumer<T, U> asBiConsumer() {
+ return (t, u) -> Uncheck.accept(this, t, u);
+ }
+
}

MODIFY
src/test/java/org/apache/commons/io/function/IOBiConsumerTest.java
src/test/java/org/apache/commons/io/function/IOBiConsumerTest.java
package org.apache.commons.io.function;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.jupiter.api.Test;
@@ -46,6 +50,17 @@ public void testAndThen() throws IOException {
assertEquals("B22B", ref.get());
}
+ @Test
+ public void testAsBiConsumer() throws IOException {
+ final Map<String, Integer> map = new HashMap<>();
+ map.put("a", 1);
+ assertThrows(UncheckedIOException.class, () -> map.forEach(TestConstants.THROWING_IO_BI_CONSUMER.asBiConsumer()));
+ final AtomicReference<String> ref = new AtomicReference<>();
+ final IOBiConsumer<String, Integer> consumer1 = (t, u) -> ref.set(t + u);
+ map.forEach(consumer1.asBiConsumer());
+ assertEquals("a1", ref.get());
+ }
+
@Test
public void testNoopIOConsumer() throws IOException {
IOBiConsumer.noop().accept(null, null);

MODIFY
src/test/java/org/apache/commons/io/function/IOConsumerTest.java
src/test/java/org/apache/commons/io/function/IOConsumerTest.java
@@ -69,7 +69,6 @@ public void testAsConsumer() throws IOException {
assertEquals("a1", ref.get());
}
-
@Test
public void testNoop() {
final Closeable nullCloseable = null;

Add IOBiConsumer#asBiConsumer()