Add missing entries for adding IOBiFunction and IOTriFunction.
Simplify to avoid ambiguous signature when inlining lambdas.
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -409,6 +409,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add PathUtils.getLastModifiedFileTime(*).
</action>
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add IOBiFunction, IOTriFunction.
+ </action>
<!-- UPDATE -->
<action dev="kinow" type="update" due-to="Dependabot, Gary Gregory">
Bump actions/cache from 2.1.6 to 3.0.5 #307, #337.

MODIFY
src/main/java/org/apache/commons/io/function/IOBiFunction.java
src/main/java/org/apache/commons/io/function/IOBiFunction.java
*/
R apply(T t, U u) throws IOException;
- /**
- * Returns a composed function that first applies this function to its input, and then applies the {@code after}
- * function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the
- * composed function.
- *
- * @param <V> the type of output of the {@code after} function, and of the composed function
- * @param after the function to apply after this function is applied
- * @return a composed function that first applies this function and then applies the {@code after} function
- * @throws NullPointerException if after is null
- */
- default <V> IOBiFunction<T, U, V> andThen(final Function<? super R, ? extends V> after) {
- Objects.requireNonNull(after);
- return (final T t, final U u) -> after.apply(apply(t, u));
- }
-
/**
* Returns a composed function that first applies this function to its input, and then applies the {@code after}
* function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the

MODIFY
src/main/java/org/apache/commons/io/function/IOTriFunction.java
src/main/java/org/apache/commons/io/function/IOTriFunction.java
return (final T t, final U u, final V v) -> after.apply(apply(t, u, v));
}
- /**
- * Returns a composed function that first applies this function to its input, and then applies the {@code after}
- * function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the
- * composed function.
- *
- * @param <W> the type of output of the {@code after} function, and of the composed function
- * @param after the function to apply after this function is applied
- * @return a composed function that first applies this function and then applies the {@code after} function
- * @throws NullPointerException if after is null
- */
- default <W> IOTriFunction<T, U, V, W> andThen(final Function<? super R, ? extends W> after) {
- Objects.requireNonNull(after);
- return (final T t, final U u, final V v) -> after.apply(apply(t, u, v));
- }
}

MODIFY
src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java
src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
-import java.util.function.Function;
import org.apache.commons.io.file.PathUtils;
import org.junit.jupiter.api.Test;
@@ -40,20 +39,6 @@ private boolean not(final boolean value) throws IOException {
return !value;
}
- /**
- * Tests {@link IOBiFunction#andThen(Function)}.
- *
- * @throws IOException thrown on test failure
- */
- @Test
- public void testAndThenFunction() throws IOException {
- final IOBiFunction<Path, LinkOption[], Boolean> isDirectory = Files::isDirectory;
- final Function<Boolean, Boolean> not = b -> !b;
- assertEquals(true, isDirectory.apply(PathUtils.current(), PathUtils.EMPTY_LINK_OPTION_ARRAY));
- final IOBiFunction<Path, LinkOption[], Boolean> andThen = isDirectory.andThen(not);
- assertEquals(false, andThen.apply(PathUtils.current(), PathUtils.EMPTY_LINK_OPTION_ARRAY));
- }
-
/**
* Tests {@link IOBiFunction#andThen(IOFunction)}.
*

MODIFY
src/test/java/org/apache/commons/io/function/IOTriFunctionTest.java
src/test/java/org/apache/commons/io/function/IOTriFunctionTest.java
import java.io.IOException;
import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Function;
import org.junit.jupiter.api.Test;
@@ -53,34 +52,6 @@ public void testAccept() throws IOException {
assertEquals("z", ref3.get());
}
- /**
- * Tests {@link IOTriFunction#andThen(Function)}.
- *
- * @throws IOException thrown on test failure
- */
- @Test
- public void testAndThenFunction() throws IOException {
- final AtomicReference<Character> ref1 = new AtomicReference<>();
- final AtomicReference<Short> ref2 = new AtomicReference<>();
- final AtomicReference<String> ref3 = new AtomicReference<>();
- final IOTriFunction<AtomicReference<Character>, AtomicReference<Short>, AtomicReference<String>, String> tri = (t, u, v) -> {
- ref1.set(Character.valueOf('a'));
- ref2.set(Short.valueOf((short) 1));
- ref3.set("z");
- return "9";
- };
- final Function<String, BigInteger> after = t -> {
- ref1.set(Character.valueOf('b'));
- ref2.set(Short.valueOf((short) 2));
- ref3.set("zz");
- return BigInteger.valueOf(Long.parseLong(t)).add(BigInteger.ONE);
- };
- assertEquals(BigInteger.TEN, tri.andThen(after).apply(ref1, ref2, ref3));
- assertEquals(Character.valueOf('b'), ref1.get());
- assertEquals(Short.valueOf((short) 2), ref2.get());
- assertEquals("zz", ref3.get());
- }
-
/**
* Tests {@link IOTriFunction#andThen(IOFunction)}.
*

Add missing entries for adding IOBiFunction and IOTriFunction.

Simplify to avoid ambiguous signature when inlining lambdas.