Package org.jeasy.batch.core.field
Class BeanFieldExtractor<P>
- java.lang.Object
-
- org.jeasy.batch.core.field.BeanFieldExtractor<P>
-
- All Implemented Interfaces:
FieldExtractor<P>
public class BeanFieldExtractor<P> extends java.lang.Object implements FieldExtractor<P>
Use JavaBean convention withIntrospector
to extract properties values from the payload of a record with optional formatting by registering a customTypeConverter
.- Author:
- RĂ©mi Alvergnat ([email protected]), Mahmoud Ben Hassine
-
-
Constructor Summary
Constructors Constructor Description BeanFieldExtractor(java.lang.Class<P> type, java.lang.String... fields)
Create a newBeanFieldExtractor
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<java.lang.Object>
extractFields(P payload)
Extract fields from the payload of a record.protected java.lang.Object
getValue(java.lang.String field, P object)
void
registerTypeConverter(TypeConverter<?,java.lang.String> typeConverter)
Register aTypeConverter
used to format fields.
-
-
-
Constructor Detail
-
BeanFieldExtractor
public BeanFieldExtractor(java.lang.Class<P> type, java.lang.String... fields)
Create a newBeanFieldExtractor
.- Parameters:
type
- of the beanfields
- to extract
-
-
Method Detail
-
extractFields
public java.lang.Iterable<java.lang.Object> extractFields(P payload) throws java.lang.Exception
Description copied from interface:FieldExtractor
Extract fields from the payload of a record.- Specified by:
extractFields
in interfaceFieldExtractor<P>
- Parameters:
payload
- of the record- Returns:
- a iterable containing fields of the record's payload
- Throws:
java.lang.Exception
- if unable to extract fields from the record's payload
-
getValue
protected java.lang.Object getValue(java.lang.String field, P object) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
- Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
-
registerTypeConverter
public void registerTypeConverter(TypeConverter<?,java.lang.String> typeConverter)
Register aTypeConverter
used to format fields.- Parameters:
typeConverter
- to register
-
-