Add IOBiFunction#asBiFunction()
MODIFY
src/main/java/org/apache/commons/io/function/IOBiFunction.java
src/main/java/org/apache/commons/io/function/IOBiFunction.java
package org.apache.commons.io.function;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.util.Objects;
+import java.util.function.BiFunction;
import java.util.function.Function;
/**
* @throws IOException if an I/O error occurs.
*/
R apply(T t, U u) throws IOException;
+
+ /**
+ * Converts this instance to a {@link BiFunction} that throws {@link UncheckedIOException} instead of
+ * {@link IOException}.
+ *
+ * @return an unchecked BiFunction.
+ */
+ default BiFunction<T, U, R> asBiFunction() {
+ return (t, u) -> Uncheck.apply(this, t, u);
+ }
}

MODIFY
src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java
src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java
package org.apache.commons.io.function;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.io.file.PathUtils;
import org.junit.jupiter.api.Test;
@@ -75,6 +78,15 @@ public void testApplyThrowsException() {
assertThrows(IOException.class, () -> isDirectory.apply(PathUtils.current(), PathUtils.EMPTY_LINK_OPTION_ARRAY));
}
+ @Test
+ public void testAsBiFunction() throws IOException {
+ final Map<String, Long> map = new HashMap<>();
+ map.put("1", 0L);
+ final IOBiFunction<String, Long, Long> f = (t, u) -> Files.size(PathUtils.current());
+ map.computeIfPresent("1", f.asBiFunction());
+ assertNotEquals(0L, map.get("1"));
+ }
+
@Test
public void testNoopIOConsumer() throws IOException {
assertNull(IOBiFunction.noop().apply(null, null));

Add IOBiFunction#asBiFunction()