com.github.skjolber.stcsv.CsvReaderStaticInitializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of databinder Show documentation
Show all versions of databinder Show documentation
High-performance CSV databinding library
package com.github.skjolber.stcsv;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.github.skjolber.stcsv.column.bi.CsvColumnValueConsumer;
import com.github.skjolber.stcsv.column.tri.CsvColumnValueTriConsumer;
public class CsvReaderStaticInitializer {
public static class CsvStaticFields {
private CsvColumnValueConsumer>[] biConsumers;
private CsvColumnValueTriConsumer, ?>[] triConsumers;
public CsvColumnValueConsumer>[] getBiConsumers() {
return biConsumers;
}
public CsvColumnValueTriConsumer, ?>[] getTriConsumers() {
return triConsumers;
}
}
/**
* {@linkplain ConcurrentHashMap} retrievals reflect the results of the most recently
* completed update operations holding upon their onset, so the classloader will
* always be able to retrieve stored values.
*/
protected static final Map values = new ConcurrentHashMap<>();
public static CsvStaticFields remove(String className) {
return values.remove(className);
}
public static void add(String className, CsvColumnValueConsumer>[] biConsumers, CsvColumnValueTriConsumer, ?>[] triConsumers) {
CsvStaticFields wrapper = new CsvStaticFields();
wrapper.biConsumers = biConsumers;
wrapper.triConsumers = triConsumers;
values.put(className, wrapper);
}
}