Skip to content

Commit 3d54ed8

Browse files
author
Gary Gregory
committed
Add missing entries for adding IOBiFunction and IOTriFunction.
Simplify to avoid ambiguous signature when inlining lambdas.
1 parent 3dfbff6 commit 3d54ed8

5 files changed

Lines changed: 3 additions & 73 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ The <action> type attribute can be add,update,fix,remove.
409409
<action dev="ggregory" type="add" due-to="Gary Gregory">
410410
Add PathUtils.getLastModifiedFileTime(*).
411411
</action>
412+
<action dev="ggregory" type="add" due-to="Gary Gregory">
413+
Add IOBiFunction, IOTriFunction.
414+
</action>
412415
<!-- UPDATE -->
413416
<action dev="kinow" type="update" due-to="Dependabot, Gary Gregory">
414417
Bump actions/cache from 2.1.6 to 3.0.5 #307, #337.

src/main/java/org/apache/commons/io/function/IOBiFunction.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,6 @@ static <T, U, R> IOBiFunction<T, U, R> noop() {
6161
*/
6262
R apply(T t, U u) throws IOException;
6363

64-
/**
65-
* Returns a composed function that first applies this function to its input, and then applies the {@code after}
66-
* function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the
67-
* composed function.
68-
*
69-
* @param <V> the type of output of the {@code after} function, and of the composed function
70-
* @param after the function to apply after this function is applied
71-
* @return a composed function that first applies this function and then applies the {@code after} function
72-
* @throws NullPointerException if after is null
73-
*/
74-
default <V> IOBiFunction<T, U, V> andThen(final Function<? super R, ? extends V> after) {
75-
Objects.requireNonNull(after);
76-
return (final T t, final U u) -> after.apply(apply(t, u));
77-
}
78-
7964
/**
8065
* Returns a composed function that first applies this function to its input, and then applies the {@code after}
8166
* function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the

src/main/java/org/apache/commons/io/function/IOTriFunction.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,4 @@ default <W> IOTriFunction<T, U, V, W> andThen(final IOFunction<? super R, ? exte
6666
return (final T t, final U u, final V v) -> after.apply(apply(t, u, v));
6767
}
6868

69-
/**
70-
* Returns a composed function that first applies this function to its input, and then applies the {@code after}
71-
* function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the
72-
* composed function.
73-
*
74-
* @param <W> the type of output of the {@code after} function, and of the composed function
75-
* @param after the function to apply after this function is applied
76-
* @return a composed function that first applies this function and then applies the {@code after} function
77-
* @throws NullPointerException if after is null
78-
*/
79-
default <W> IOTriFunction<T, U, V, W> andThen(final Function<? super R, ? extends W> after) {
80-
Objects.requireNonNull(after);
81-
return (final T t, final U u, final V v) -> after.apply(apply(t, u, v));
82-
}
8369
}

src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.nio.file.Files;
2626
import java.nio.file.LinkOption;
2727
import java.nio.file.Path;
28-
import java.util.function.Function;
2928

3029
import org.apache.commons.io.file.PathUtils;
3130
import org.junit.jupiter.api.Test;
@@ -40,20 +39,6 @@ private boolean not(final boolean value) throws IOException {
4039
return !value;
4140
}
4241

43-
/**
44-
* Tests {@link IOBiFunction#andThen(Function)}.
45-
*
46-
* @throws IOException thrown on test failure
47-
*/
48-
@Test
49-
public void testAndThenFunction() throws IOException {
50-
final IOBiFunction<Path, LinkOption[], Boolean> isDirectory = Files::isDirectory;
51-
final Function<Boolean, Boolean> not = b -> !b;
52-
assertEquals(true, isDirectory.apply(PathUtils.current(), PathUtils.EMPTY_LINK_OPTION_ARRAY));
53-
final IOBiFunction<Path, LinkOption[], Boolean> andThen = isDirectory.andThen(not);
54-
assertEquals(false, andThen.apply(PathUtils.current(), PathUtils.EMPTY_LINK_OPTION_ARRAY));
55-
}
56-
5742
/**
5843
* Tests {@link IOBiFunction#andThen(IOFunction)}.
5944
*

src/test/java/org/apache/commons/io/function/IOTriFunctionTest.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.IOException;
2323
import java.math.BigInteger;
2424
import java.util.concurrent.atomic.AtomicReference;
25-
import java.util.function.Function;
2625

2726
import org.junit.jupiter.api.Test;
2827

@@ -53,34 +52,6 @@ public void testAccept() throws IOException {
5352
assertEquals("z", ref3.get());
5453
}
5554

56-
/**
57-
* Tests {@link IOTriFunction#andThen(Function)}.
58-
*
59-
* @throws IOException thrown on test failure
60-
*/
61-
@Test
62-
public void testAndThenFunction() throws IOException {
63-
final AtomicReference<Character> ref1 = new AtomicReference<>();
64-
final AtomicReference<Short> ref2 = new AtomicReference<>();
65-
final AtomicReference<String> ref3 = new AtomicReference<>();
66-
final IOTriFunction<AtomicReference<Character>, AtomicReference<Short>, AtomicReference<String>, String> tri = (t, u, v) -> {
67-
ref1.set(Character.valueOf('a'));
68-
ref2.set(Short.valueOf((short) 1));
69-
ref3.set("z");
70-
return "9";
71-
};
72-
final Function<String, BigInteger> after = t -> {
73-
ref1.set(Character.valueOf('b'));
74-
ref2.set(Short.valueOf((short) 2));
75-
ref3.set("zz");
76-
return BigInteger.valueOf(Long.parseLong(t)).add(BigInteger.ONE);
77-
};
78-
assertEquals(BigInteger.TEN, tri.andThen(after).apply(ref1, ref2, ref3));
79-
assertEquals(Character.valueOf('b'), ref1.get());
80-
assertEquals(Short.valueOf((short) 2), ref2.get());
81-
assertEquals("zz", ref3.get());
82-
}
83-
8455
/**
8556
* Tests {@link IOTriFunction#andThen(IOFunction)}.
8657
*

0 commit comments

Comments
 (0)