Class BeanFieldExtractor<P>

  • All Implemented Interfaces:
    FieldExtractor<P>

    public class BeanFieldExtractor<P>
    extends java.lang.Object
    implements FieldExtractor<P>
    Use JavaBean convention with Introspector to extract properties values from the payload of a record with optional formatting by registering a custom TypeConverter.
    Author:
    RĂ©mi Alvergnat ([email protected]), Mahmoud Ben Hassine
    • 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 a TypeConverter used to format fields.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BeanFieldExtractor

        public BeanFieldExtractor​(java.lang.Class<P> type,
                                  java.lang.String... fields)
        Create a new BeanFieldExtractor.
        Parameters:
        type - of the bean
        fields - 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 interface FieldExtractor<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 a TypeConverter used to format fields.
        Parameters:
        typeConverter - to register