1 package com.opencsv.bean;
2
3 import com.opencsv.exceptions.CsvConstraintViolationException;
4
5 /**
6 * Classes implementing this interface may be used to verify and filter beans
7 * after creation, but before being passed back to the calling application.
8 * This is fully intended as a replacement for {@link CsvToBeanFilter}.
9 * <p>Implementations of this interface <em>must</em> be thread-safe.</p>
10 *
11 * @param <T> The type of bean being verified
12 * @since 4.4
13 * @author Andrew Rucker Jones
14 */
15 public interface BeanVerifier<T> {
16
17 /**
18 * Verifies and optionally filters the bean that has been created.
19 * This method throws {@link CsvConstraintViolationException} if the bean
20 * created is in some way inconsistent and thus unacceptable. If, however,
21 * the bean is essentially correct, but for some logical reason should be
22 * filtered silently out, the method should return {@code false}.
23 *
24 * @param bean The bean to be verified
25 * @return {@code true} if the bean should be passed on to further
26 * processing, {@code false} if it should be silently filtered
27 * @throws CsvConstraintViolationException If the bean that has been
28 * created is in some way logically inconsistent or impossible. This
29 * exception will be propagated up the call stack and, depending on how
30 * opencsv is being used, may simply be reported, or may halt execution.
31 */
32 boolean verifyBean(T bean) throws CsvConstraintViolationException;
33 }