1 package com.opencsv.bean.function;
2
3 import java.lang.reflect.InvocationTargetException;
4
5 /**
6 * Functional interface for accessing a value from a field.
7 * <p>The field must be part of the code created for this functional interface,
8 * as there is no way to pass the field in during invocation.</p>
9 * <p>This interface is almost identical to {@link java.util.function.Function}
10 * save the exceptions thrown, which is the reason for its existence.</p>
11 *
12 * @param <T> The type of the object from which the value should be retrieved
13 * @param <R> The type of the return value
14 * @author Andrew Rucker Jones
15 * @since 5.0
16 */
17 @FunctionalInterface
18 public interface AccessorInvoker<T, R> {
19
20 /**
21 * Invoke the code to retrieve a value from a field.
22 *
23 * @param object The object from which the value of the field should be
24 * retrieved
25 * @return The value of the field from the given object
26 * @throws IllegalAccessException If retrieval causes a problem
27 * @throws InvocationTargetException If retrieval causes a problem
28 */
29 R invoke(T object) throws IllegalAccessException, InvocationTargetException;
30 }