2424import java .util .Collection ;
2525import java .util .Collections ;
2626import java .util .Objects ;
27- import java .util .function .Predicate ;
2827import java .util .stream .Stream ;
2928
3029import org .apache .commons .io .IOExceptionList ;
4746 */
4847public class FilterCollectionWriter extends Writer {
4948
50- @ SuppressWarnings ("rawtypes" )
51- private static final Predicate NOT_NULL = Objects ::nonNull ;
52-
53- @ SuppressWarnings ("unchecked" )
54- private static <T > Predicate <T > notNull () {
55- return NOT_NULL ;
56- }
57-
5849 /**
5950 * Empty and immutable collection of writers.
6051 */
@@ -85,20 +76,17 @@ protected FilterCollectionWriter(final Writer... writers) {
8576
8677 @ Override
8778 public Writer append (final char c ) throws IOException {
88- forAllWriters (w -> w .append (c ));
89- return this ;
79+ return forAllWriters (w -> w .append (c ));
9080 }
9181
9282 @ Override
9383 public Writer append (final CharSequence csq ) throws IOException {
94- forAllWriters (w -> w .append (csq ));
95- return this ;
84+ return forAllWriters (w -> w .append (csq ));
9685 }
9786
9887 @ Override
9988 public Writer append (final CharSequence csq , final int start , final int end ) throws IOException {
100- forAllWriters (w -> w .append (csq , start , end ));
101- return this ;
89+ return forAllWriters (w -> w .append (csq , start , end ));
10290 }
10391
10492 @ Override
@@ -116,8 +104,9 @@ public void flush() throws IOException {
116104 forAllWriters (Writer ::flush );
117105 }
118106
119- private void forAllWriters (final IOConsumer <Writer > action ) throws IOExceptionList {
107+ private FilterCollectionWriter forAllWriters (final IOConsumer <Writer > action ) throws IOExceptionList {
120108 IOConsumer .forAll (writers (), action );
109+ return this ;
121110 }
122111
123112 @ Override
@@ -169,7 +158,7 @@ public void write(final String str, final int off, final int len) throws IOExcep
169158 }
170159
171160 private Stream <Writer > writers () {
172- return writers .stream ().filter (notNull () );
161+ return writers .stream ().filter (Objects :: nonNull );
173162 }
174163
175164}
0 commit comments