Interface FieldModifier

All Known Implementing Classes:
FieldModifiers

public interface FieldModifier
Implementations of this class are used within CsvCallbackHandler implementations to modify the fields of a CSV record before storing them in the resulting object.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Chains multiple modifiers.
    default String
    modify(long startingLineNumber, int fieldIdx, boolean quoted, String field)
    Gets called for every single field (that is not a comment).
    modify(Function<? super String, String> function)
    Builds a modifier that modifies the field value using the provided function.
    default String
    modifyComment(long startingLineNumber, String field)
    Gets called for every comment.
  • Method Details

    • modify

      static FieldModifier modify(Function<? super String, String> function)
      Builds a modifier that modifies the field value using the provided function. Comments are not modified.
      Parameters:
      function - the function to modify the field value. The contract of modify(long, int, boolean, String) applies: the value passed to the function is never null and the return value must not be null.
      Returns:
      a new field modifier that applies the function to the field value
      Throws:
      NullPointerException - if the function is null
    • modify

      default String modify(long startingLineNumber, int fieldIdx, boolean quoted, String field)
      Gets called for every single field (that is not a comment). The Default implementation returns the field as is.
      Parameters:
      startingLineNumber - the starting line number (starting with 1)
      fieldIdx - the field index (starting with 0)
      quoted - true if the field was enclosed by the defined quote characters
      field - the field value, never null
      Returns:
      the modified field value (must not be null)
    • modifyComment

      default String modifyComment(long startingLineNumber, String field)
      Gets called for every comment. The Default implementation returns the field as is.
      Parameters:
      startingLineNumber - the starting line number (starting with 1)
      field - the field value (comment), never null
      Returns:
      the modified field value (must not be null)
    • andThen

      default FieldModifier andThen(FieldModifier after)
      Chains multiple modifiers.
      Parameters:
      after - the next modifier to use.
      Returns:
      a composed field modifier that first applies this modifier and then applies the after modifier