Top Description Methods
de.siegmar.fastcsv.reader

public Interface FieldModifier

Known Direct Implementers
de.siegmar.fastcsv.reader.FieldModifiers
Imports
java.util.Objects, java.util.function.Function

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
FieldModifiers

Method Summary

Modifier and TypeMethod and Description
public default FieldModifier

Returns:

a composed field modifier that first applies this modifier and then applies the after modifier
andThen
(final FieldModifier
the next modifier to use.
after
)

Chains multiple modifiers.

public static FieldModifier

Returns:

a new field modifier that applies the function to the field value
modify
(final Function<? super String, String>
the function to modify the field value. The contract of FieldModifier#modify(long, int, boolean, String) applies: the value passed to the function is never null and the return value must not be null.
function
)

Builds a modifier that modifies the field value using the provided function.

public default String

Returns:

the modified field value (must not be null)
modify
(final long
the starting line number (starting with 1)
startingLineNumber
,
final int
the field index (starting with 0)
fieldIdx
,
final boolean
true if the field was enclosed by the defined quote characters
quoted
,
final String
the field value, never null
field
)

Gets called for every single field (that is not a comment).

public default String

Returns:

the modified field value (must not be null)
modifyComment
(final long
the starting line number (starting with 1)
startingLineNumber
,
final String
the field value (comment), never null
field
)

Gets called for every comment.

Method Detail

andThenback to summary
public default FieldModifier andThen(final FieldModifier after)

Chains multiple modifiers.

Parameters
after:FieldModifier

the next modifier to use.

Returns:FieldModifier

a composed field modifier that first applies this modifier and then applies the after modifier

modifyback to summary
public static FieldModifier modify(final Function<? super String, String> function)

Builds a modifier that modifies the field value using the provided function. Comments are not modified.

Parameters
function:Function<? super String, String>

the function to modify the field value. The contract of FieldModifier#modify(long, int, boolean, String) applies: the value passed to the function is never null and the return value must not be null.

Returns:FieldModifier

a new field modifier that applies the function to the field value

Exceptions
NullPointerException:
if the function is null
modifyback to summary
public default String modify(final long startingLineNumber, final int fieldIdx, final boolean quoted, final String field)

Gets called for every single field (that is not a comment). The Default implementation returns the field as is.

Parameters
startingLineNumber:long

the starting line number (starting with 1)

fieldIdx:int

the field index (starting with 0)

quoted:boolean

true if the field was enclosed by the defined quote characters

field:String

the field value, never null

Returns:String

the modified field value (must not be null)

modifyCommentback to summary
public default String modifyComment(final long startingLineNumber, final String field)

Gets called for every comment. The Default implementation returns the field as is.

Parameters
startingLineNumber:long

the starting line number (starting with 1)

field:String

the field value (comment), never null

Returns:String

the modified field value (must not be null)