1 package com.opencsv.bean.exceptionhandler;
2
3 import com.opencsv.exceptions.CsvException;
4
5 import java.util.concurrent.atomic.AtomicInteger;
6
7
8
9
10
11
12
13 final public class ExceptionHandlerIgnoreThenThrowAfter implements CsvExceptionHandler {
14
15 private final AtomicInteger count = new AtomicInteger();
16 private final int maxExceptions;
17
18
19
20
21
22
23 public ExceptionHandlerIgnoreThenThrowAfter(int maxExceptions) {
24 this.maxExceptions = maxExceptions;
25 }
26
27 @Override
28 public CsvException handleException(CsvException e) throws CsvException {
29 if(count.incrementAndGet() > maxExceptions) {
30 throw e;
31 }
32 return null;
33 }
34 }