Package com.opencsv.bean
Class FieldAccess<T>
java.lang.Object
com.opencsv.bean.FieldAccess<T>
- Type Parameters:
T
- The type of the member variable being accessed
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
Optional
, wrap or unwrap as necessary. EmptyOptional
s lead tonull
return values, andnull
values lead to emptyOptional
s. - Use reflection bypassing all access control restrictions.
- Since:
- 5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AccessorInvoker
<Object, T> A functional interface to read the field.private final AssignmentInvoker
<Object, T> A functional interface to write the field.private final Field
The field being accessed. -
Constructor Summary
ConstructorsConstructorDescriptionFieldAccess
(Field field) Constructs this instance by determining what mode of access will work for this field. -
Method Summary
Modifier and TypeMethodDescriptionprivate AccessorInvoker
<Object, T> private AssignmentInvoker
<Object, T> boolean
Determines equality between this object and another.Returns the value of the field in the given bean.int
hashCode()
Creates a hash code for this object.void
Sets the value of the field in the given bean.toString()
Returns a string representation of this object.
-
Field Details
-
field
The field being accessed. -
accessor
A functional interface to read the field. -
assignment
A functional interface to write the field.
-
-
Constructor Details
-
FieldAccess
Constructs this instance by determining what mode of access will work for this field.- Parameters:
field
- The field to be accessed.
-
-
Method Details
-
determineAccessorMethod
-
determineAssignmentMethod
-
getField
Returns the value of the field in the given bean.- Parameters:
bean
- The bean from which the value of this field should be returned- Returns:
- The value of this member variable
- Throws:
IllegalAccessException
- If there is a problem accessing the member variableInvocationTargetException
- If there is a problem accessing the member variable
-
setField
Sets the value of the field in the given bean.- Parameters:
bean
- The bean in which the value of the field should be setvalue
- The value to be written into the member variable of the bean- Throws:
IllegalAccessException
- If there is a problem accessing the member variableInvocationTargetException
- If there is a problem accessing the member variable
-
hashCode
public int hashCode()Creates a hash code for this object. This override delegates hash code creation to the field passed in through the constructor and does not includes any of its own state information. -
equals
Determines equality between this object and another. This override delegates equality determination to the field passed in through the constructor and does not includes any of its own state information. -
toString
Returns a string representation of this object. This override delegates the string representation to the field passed in through the constructor and does not includes any of its own state information.
-