public class FieldMapping
extends java.lang.Object
Parsed
in a record.Modifier and Type | Field and Description |
---|---|
private boolean |
accessible |
private java.lang.Boolean |
applyDefault |
private java.lang.Class<?> |
beanClass |
private java.lang.Object |
defaultPrimitiveValue |
private java.lang.String |
fieldName |
private int |
index |
private java.lang.Class |
parentClass |
private boolean |
primitive |
private java.lang.reflect.Method |
readMethod |
private java.lang.reflect.AnnotatedElement |
target |
private java.lang.reflect.Method |
writeMethod |
Constructor and Description |
---|
FieldMapping(java.lang.Class<?> beanClass,
java.lang.reflect.AnnotatedElement target,
PropertyWrapper property,
HeaderTransformer transformer,
java.lang.String[] headers)
Creates the mapping and identifies how it is mapped (by name or by index)
|
Modifier and Type | Method and Description |
---|---|
boolean |
canWrite(java.lang.Object instance)
Queries whether this field mapping can be applied over a given object instance.
|
private void |
determineFieldMapping(HeaderTransformer transformer,
java.lang.String[] headers) |
boolean |
equals(java.lang.Object o) |
java.lang.String |
getFieldName()
Returns the column name against which this field is mapped.
|
java.lang.Class<?> |
getFieldParent()
Returns the parent class that contains the mapped field.
|
java.lang.Class<?> |
getFieldType()
Returns the type of the mapped field
|
int |
getIndex()
Returns the column index against which this field is mapped.
|
java.lang.reflect.AnnotatedElement |
getTarget()
Returns the
Field mapped to a column |
int |
hashCode() |
boolean |
isMappedToField()
Returns
true if the field is mapped to a column name, otherwise false |
boolean |
isMappedToIndex()
Returns
true if the field is mapped to a column index, otherwise false |
java.lang.Object |
read(java.lang.Object instance)
Reads the value accessible by this field mapping from a given object
|
private java.lang.Object |
read(java.lang.Object instance,
boolean ignoreErrors) |
private void |
setAccessible() |
void |
setFieldName(java.lang.String fieldName)
Defines the column name against which this field is mapped, overriding any current name derived from
annotations or from the attribute name itself.
|
java.lang.String |
toString() |
void |
write(java.lang.Object instance,
java.lang.Object value)
Writes a value to the field of a given object instance, whose field is accessible through this field mapping.
|
private final java.lang.Class parentClass
private final java.lang.reflect.AnnotatedElement target
private int index
private java.lang.String fieldName
private final java.lang.Class<?> beanClass
private final java.lang.reflect.Method readMethod
private final java.lang.reflect.Method writeMethod
private boolean accessible
private final boolean primitive
private final java.lang.Object defaultPrimitiveValue
private java.lang.Boolean applyDefault
public FieldMapping(java.lang.Class<?> beanClass, java.lang.reflect.AnnotatedElement target, PropertyWrapper property, HeaderTransformer transformer, java.lang.String[] headers)
beanClass
- the class that contains a the given field.target
- a Field
or Method
annotated with Parsed
property
- the property descriptor of this field, if any. If this bean does not have getters/setters, it will be accessed directly.transformer
- an optional HeaderTransformer
to modify header names/positions in attributes of Nested
classes.headers
- list of headers parsed from the input or manually set with CommonSettings.setHeaders(String...)
private void determineFieldMapping(HeaderTransformer transformer, java.lang.String[] headers)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean isMappedToIndex()
true
if the field is mapped to a column index, otherwise false
true
if the field is mapped to a column index, otherwise false
public boolean isMappedToField()
true
if the field is mapped to a column name, otherwise false
true
if the field is mapped to a column name, otherwise false
public int getIndex()
public void setFieldName(java.lang.String fieldName)
fieldName
- the column name associated with this fieldpublic java.lang.String getFieldName()
null
if there's no such association.public java.lang.reflect.AnnotatedElement getTarget()
Field
mapped to a columnField
mapped to a columnprivate void setAccessible()
public java.lang.Class<?> getFieldParent()
public java.lang.Class<?> getFieldType()
public boolean canWrite(java.lang.Object instance)
instance
- the object whose type will be verified in order to identify if it contains the mapped fieldtrue
if the given instance contains the field/accessor method and can use this field mapping to modify its internal state; otherwise false
public java.lang.Object read(java.lang.Object instance)
instance
- the object whose field, mapped by this field mapping, will be readprivate java.lang.Object read(java.lang.Object instance, boolean ignoreErrors)
public void write(java.lang.Object instance, java.lang.Object value)
instance
- the object whose field will be setvalue
- the value to set on the given object's field.public java.lang.String toString()
toString
in class java.lang.Object