public class FieldMapping
extends java.lang.Object
Parsed in a record.| 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.
|
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
|
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.
|
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 Parsedproperty - 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...)public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean isMappedToIndex()
true if the field is mapped to a column index, otherwise falsetrue if the field is mapped to a column index, otherwise falsepublic boolean isMappedToField()
true if the field is mapped to a column name, otherwise falsetrue if the field is mapped to a column name, otherwise falsepublic 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 columnpublic 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 falsepublic java.lang.Object read(java.lang.Object instance)
instance - the object whose field, mapped by this field mapping, will be readpublic 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