@@ -81,7 +81,7 @@ protected FilterCollectionWriter(final Writer... writers) {
8181 * @param e The cause.
8282 * @return the given list or a new list on null input.
8383 */
84- private List <Exception > add (List <Exception > causeList , final int i , final IOException e ) {
84+ private List <IOException > add (List <IOException > causeList , final int i , final IOException e ) {
8585 if (causeList == null ) {
8686 causeList = new ArrayList <>();
8787 }
@@ -91,7 +91,7 @@ private List<Exception> add(List<Exception> causeList, final int i, final IOExce
9191
9292 @ Override
9393 public Writer append (final char c ) throws IOException {
94- List <Exception > causeList = null ;
94+ List <IOException > causeList = null ;
9595 int i = 0 ;
9696 for (final Writer w : writers ) {
9797 if (w != null ) {
@@ -103,15 +103,13 @@ public Writer append(final char c) throws IOException {
103103 }
104104 i ++;
105105 }
106- if (notEmpty (causeList )) {
107- throw new IOExceptionList ("append" , causeList );
108- }
106+ IOExceptionList .checkEmpty (causeList , "append(char)" );
109107 return this ;
110108 }
111109
112110 @ Override
113111 public Writer append (final CharSequence csq ) throws IOException {
114- List <Exception > causeList = null ;
112+ List <IOException > causeList = null ;
115113 int i = 0 ;
116114 for (final Writer w : writers ) {
117115 if (w != null ) {
@@ -123,16 +121,14 @@ public Writer append(final CharSequence csq) throws IOException {
123121 }
124122 i ++;
125123 }
126- if (notEmpty (causeList )) {
127- throw new IOExceptionList ("append" , causeList );
128- }
124+ IOExceptionList .checkEmpty (causeList , "append(CharSequence)" );
129125 return this ;
130126 }
131127
132128 @ Override
133129 public Writer append (final CharSequence csq , final int start , final int end ) throws IOException {
134130
135- List <Exception > causeList = null ;
131+ List <IOException > causeList = null ;
136132 int i = 0 ;
137133 for (final Writer w : writers ) {
138134 if (w != null ) {
@@ -144,15 +140,13 @@ public Writer append(final CharSequence csq, final int start, final int end) thr
144140 }
145141 i ++;
146142 }
147- if (notEmpty (causeList )) {
148- throw new IOExceptionList ("append" , causeList );
149- }
143+ IOExceptionList .checkEmpty (causeList , "append(CharSequence, int, int)" );
150144 return this ;
151145 }
152146
153147 @ Override
154148 public void close () throws IOException {
155- List <Exception > causeList = null ;
149+ List <IOException > causeList = null ;
156150 int i = 0 ;
157151 for (final Writer w : writers ) {
158152 if (w != null ) {
@@ -164,10 +158,7 @@ public void close() throws IOException {
164158 }
165159 i ++;
166160 }
167- if (notEmpty (causeList )) {
168- throw new IOExceptionList ("close" , causeList );
169- }
170-
161+ IOExceptionList .checkEmpty (causeList , "close()" );
171162 }
172163
173164 /**
@@ -177,7 +168,7 @@ public void close() throws IOException {
177168 */
178169 @ Override
179170 public void flush () throws IOException {
180- List <Exception > causeList = null ;
171+ List <IOException > causeList = null ;
181172 int i = 0 ;
182173 for (final Writer w : writers ) {
183174 if (w != null ) {
@@ -189,25 +180,12 @@ public void flush() throws IOException {
189180 }
190181 i ++;
191182 }
192- if (notEmpty (causeList )) {
193- throw new IOExceptionList ("flush" , causeList );
194- }
195-
196- }
197-
198- /**
199- * Tests if the given list is empty in a null-safe manner.
200- *
201- * @param causeList the list to test.
202- * @return true if empty or null.
203- */
204- private boolean notEmpty (final List <Exception > causeList ) {
205- return causeList != null && !causeList .isEmpty ();
183+ IOExceptionList .checkEmpty (causeList , "flush()" );
206184 }
207185
208186 @ Override
209187 public void write (final char [] cbuf ) throws IOException {
210- List <Exception > causeList = null ;
188+ List <IOException > causeList = null ;
211189 int i = 0 ;
212190 for (final Writer w : writers ) {
213191 if (w != null ) {
@@ -219,9 +197,7 @@ public void write(final char[] cbuf) throws IOException {
219197 }
220198 i ++;
221199 }
222- if (notEmpty (causeList )) {
223- throw new IOExceptionList ("write" , causeList );
224- }
200+ IOExceptionList .checkEmpty (causeList , "write(char[])" );
225201 }
226202
227203 /**
@@ -235,7 +211,7 @@ public void write(final char[] cbuf) throws IOException {
235211 */
236212 @ Override
237213 public void write (final char [] cbuf , final int off , final int len ) throws IOException {
238- List <Exception > causeList = null ;
214+ List <IOException > causeList = null ;
239215 int i = 0 ;
240216 for (final Writer w : writers ) {
241217 if (w != null ) {
@@ -247,9 +223,7 @@ public void write(final char[] cbuf, final int off, final int len) throws IOExce
247223 }
248224 i ++;
249225 }
250- if (notEmpty (causeList )) {
251- throw new IOExceptionList ("write" , causeList );
252- }
226+ IOExceptionList .checkEmpty (causeList , "write(char[], int, int)" );
253227 }
254228
255229 /**
@@ -259,7 +233,7 @@ public void write(final char[] cbuf, final int off, final int len) throws IOExce
259233 */
260234 @ Override
261235 public void write (final int c ) throws IOException {
262- List <Exception > causeList = null ;
236+ List <IOException > causeList = null ;
263237 int i = 0 ;
264238 for (final Writer w : writers ) {
265239 if (w != null ) {
@@ -271,14 +245,12 @@ public void write(final int c) throws IOException {
271245 }
272246 i ++;
273247 }
274- if (notEmpty (causeList )) {
275- throw new IOExceptionList ("write" , causeList );
276- }
248+ IOExceptionList .checkEmpty (causeList , "write(int)" );
277249 }
278250
279251 @ Override
280252 public void write (final String str ) throws IOException {
281- List <Exception > causeList = null ;
253+ List <IOException > causeList = null ;
282254 int i = 0 ;
283255 for (final Writer w : writers ) {
284256 if (w != null ) {
@@ -290,10 +262,7 @@ public void write(final String str) throws IOException {
290262 }
291263 i ++;
292264 }
293- if (notEmpty (causeList )) {
294- throw new IOExceptionList ("write" , causeList );
295- }
296-
265+ IOExceptionList .checkEmpty (causeList , "write(String)" );
297266 }
298267
299268 /**
@@ -307,7 +276,7 @@ public void write(final String str) throws IOException {
307276 */
308277 @ Override
309278 public void write (final String str , final int off , final int len ) throws IOException {
310- List <Exception > causeList = null ;
279+ List <IOException > causeList = null ;
311280 int i = 0 ;
312281 for (final Writer w : writers ) {
313282 if (w != null ) {
@@ -319,10 +288,7 @@ public void write(final String str, final int off, final int len) throws IOExcep
319288 }
320289 i ++;
321290 }
322- if (notEmpty (causeList )) {
323- throw new IOExceptionList ("write" , causeList );
324- }
325-
291+ IOExceptionList .checkEmpty (causeList , "write(String, int, int)" );
326292 }
327293
328294}
0 commit comments