Class FieldModifiers
java.lang.Object
de.siegmar.fastcsv.reader.FieldModifiers
Provides some common FieldModifier implementations.
Example usage:
FieldModifier modifier = FieldModifiers.TRIM
.andThen(FieldModifiers.modify(field -> field.toUpperCase(Locale.ENGLISH)));
CsvRecordHandler handler = CsvRecordHandler.of(c -> c.fieldModifier(modifier));
List<CsvRecord> records = CsvReader.builder()
.build(handler, " foo , bar")
.stream()
.collect(Collectors.toList());
// fields would be: "FOO" and "BAR"
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FieldModifierModifier that does not modify anything.static final FieldModifierModifier that modifies the field value withString.strip().static final FieldModifierModifier that modifies the field value withString.trim(). -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldModifierDeprecated, for removal: This API element is subject to removal in a future version.static FieldModifierBuilds a modifier that modifies the field value using the provided function.static FieldModifierDeprecated, for removal: This API element is subject to removal in a future version.Usemodify(Function)instead.
-
Field Details
-
NOP
Modifier that does not modify anything. -
TRIM
Modifier that modifies the field value withString.trim(). Comments are not modified. -
STRIP
Modifier that modifies the field value withString.strip(). Comments are not modified.
-
-
Method Details
-
lower
Deprecated, for removal: This API element is subject to removal in a future version.Usemodify(Function)instead.Builds modifier that modifies the field value withString.toLowerCase(Locale). Comments are not modified.- Parameters:
locale- use the case transformation rules for this locale- Returns:
- a new field modifier that converts the input to lower-case.
-
upper
Deprecated, for removal: This API element is subject to removal in a future version.Usemodify(Function)instead.Builds modifier that modifies the field value withString.toUpperCase(Locale). Comments are not modified.- Parameters:
locale- use the case transformation rules for this locale- Returns:
- a new field modifier that converts the input to upper-case.
-
modify
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 ofFieldModifier.modify(long, int, boolean, String)applies: the value passed to the function is nevernulland the return value must not benull.- Returns:
- a new field modifier that applies the function to the field value
- Throws:
NullPointerException- if the function isnull
-
modify(Function)instead.