Skip to content

Commit

Permalink
remove simple mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
osiegmar committed Jan 10, 2024
1 parent 773a222 commit ffa3cfa
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 81 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package de.siegmar.fastcsv.reader;

import java.util.Objects;

/**
* This class defines the methods that are called during the CSV reading process.
* <p>
* Implementations highly affect the behavior of the {@link CsvReader}. With great power comes great responsibility.
* Don't mess up the CSV reading process!
* <p>
* Even if you need custom handling, you typically don't need to extend this class directly.
* Check out {@link #forSimpleMapper(SimpleCsvMapper)} and {@link AbstractBaseCsvCallbackHandler} first.
* Check out {@link AbstractBaseCsvCallbackHandler} first.
*
* @param <T> the type of the record that is built from the CSV data
*/
Expand All @@ -22,26 +20,6 @@ public abstract class CsvCallbackHandler<T> {
protected CsvCallbackHandler() {
}

/**
* Constructs a callback handler for the given {@link SimpleCsvMapper}.
* <p>
* The returned callback handler is stateful and must not be reused.
*
* @param <T> the type of the resulting records
* @param mapper the mapper
* @return a callback handler that returns a mapped record for each record
* @throws NullPointerException if {@code mapper} is {@code null}
*/
public static <T> CsvCallbackHandler<T> forSimpleMapper(final SimpleCsvMapper<T> mapper) {
Objects.requireNonNull(mapper, "mapper must not be null");
return new AbstractCsvCallbackHandler<>() {
@Override
protected RecordWrapper<T> buildRecord() {
return buildWrapper(mapper.map(compactFields()));
}
};
}

/**
* Called at the beginning of each record.
* <p>
Expand Down
21 changes: 0 additions & 21 deletions lib/src/main/java/de/siegmar/fastcsv/reader/SimpleCsvMapper.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ void stringArrayFieldModifier() {
.containsExactly("foo", "bar");
}

@Test
void simpleMapper() {
final CsvCallbackHandler<String[]> rh = CsvCallbackHandler
.forSimpleMapper(fields -> new String[]{fields[1], fields[0]});
process(rh);

assertThat(rh.buildRecord().wrappedRecord())
.containsExactly("bar", "foo");
}

private static void process(final CsvCallbackHandler<?> rh) {
rh.beginRecord(1);
addField(rh, "foo");
Expand Down

0 comments on commit ffa3cfa

Please sign in to comment.