tech.tablesaw.io.WriterRegistry Maven / Gradle / Ivy
The newest version!
package tech.tablesaw.io;
import java.util.HashMap;
import java.util.Map;
public class WriterRegistry {
private final Map> optionTypesRegistry = new HashMap<>();
private final Map> extensionsRegistry = new HashMap<>();
public void registerOptions(Class extends WriteOptions> optionsType, DataWriter> writer) {
optionTypesRegistry.put(optionsType.getCanonicalName(), writer);
}
public void registerExtension(String extension, DataWriter> writer) {
extensionsRegistry.put(extension, writer);
}
@SuppressWarnings("unchecked")
public DataWriter getWriterForOptions(T options) {
return (DataWriter) optionTypesRegistry.get(options.getClass().getCanonicalName());
}
public DataWriter> getWriterForExtension(String extension) {
return extensionsRegistry.get(extension);
}
}