This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 63771b3f142c2ac42aca8b864d3df03aa2a46b94 Author: Gary Gregory <[email protected]> AuthorDate: Thu Jul 21 08:49:07 2022 -0400 Internal refactoring --- .../commons/io/output/FilterCollectionWriter.java | 23 ++++++---------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/commons/io/output/FilterCollectionWriter.java b/src/main/java/org/apache/commons/io/output/FilterCollectionWriter.java index 579951aa..43cb981a 100644 --- a/src/main/java/org/apache/commons/io/output/FilterCollectionWriter.java +++ b/src/main/java/org/apache/commons/io/output/FilterCollectionWriter.java @@ -24,7 +24,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Objects; -import java.util.function.Predicate; import java.util.stream.Stream; import org.apache.commons.io.IOExceptionList; @@ -47,14 +46,6 @@ import org.apache.commons.io.function.IOConsumer; */ public class FilterCollectionWriter extends Writer { - @SuppressWarnings("rawtypes") - private static final Predicate NOT_NULL = Objects::nonNull; - - @SuppressWarnings("unchecked") - private static <T> Predicate<T> notNull() { - return NOT_NULL; - } - /** * Empty and immutable collection of writers. */ @@ -85,20 +76,17 @@ public class FilterCollectionWriter extends Writer { @Override public Writer append(final char c) throws IOException { - forAllWriters(w -> w.append(c)); - return this; + return forAllWriters(w -> w.append(c)); } @Override public Writer append(final CharSequence csq) throws IOException { - forAllWriters(w -> w.append(csq)); - return this; + return forAllWriters(w -> w.append(csq)); } @Override public Writer append(final CharSequence csq, final int start, final int end) throws IOException { - forAllWriters(w -> w.append(csq, start, end)); - return this; + return forAllWriters(w -> w.append(csq, start, end)); } @Override @@ -116,8 +104,9 @@ public class FilterCollectionWriter extends Writer { forAllWriters(Writer::flush); } - private void forAllWriters(final IOConsumer<Writer> action) throws IOExceptionList { + private FilterCollectionWriter forAllWriters(final IOConsumer<Writer> action) throws IOExceptionList { IOConsumer.forAll(writers(), action); + return this; } @Override @@ -169,7 +158,7 @@ public class FilterCollectionWriter extends Writer { } private Stream<Writer> writers() { - return writers.stream().filter(notNull()); + return writers.stream().filter(Objects::nonNull); } }
