com.opencsv.bean.FieldAccess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opencsv Show documentation
Show all versions of opencsv Show documentation
A simple library for reading and writing CSV in Java
package com.opencsv.bean;
import com.opencsv.bean.function.AccessorInvoker;
import com.opencsv.bean.function.AssignmentInvoker;
import org.apache.commons.lang3.reflect.FieldUtils;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Optional;
/**
* Encapsulates the logic for accessing member variables of classes.
* The logic in opencsv is always:
* - Use an accessor method first, if available, and this always has the
* form "get"/"set" + member name with initial capital.
* - If this accessor method is available but deals in
* {@link java.util.Optional}, wrap or unwrap as necessary. Empty
* {@link java.util.Optional}s lead to {@code null} return values, and
* {@code null} values lead to empty {@link java.util.Optional}s.
* - Use reflection bypassing all access control restrictions.
*
These are considered separately for reading and writing.
*
* @param The type of the member variable being accessed
* @author Andrew Rucker Jones
* @since 5.0
*/
public class FieldAccess {
/** The field being accessed. */
private final Field field;
/** A functional interface to read the field. */
private final AccessorInvoker