All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.tablesaw.io.ReaderRegistry Maven / Gradle / Ivy

package tech.tablesaw.io;

import java.util.HashMap;
import java.util.Map;

public class ReaderRegistry {

    private final Map> optionTypesRegistry = new HashMap<>();

    private final Map> extensionsRegistry = new HashMap<>();

    private final Map> mimeTypesRegistry = new HashMap<>();


    public void registerOptions(Class optionsType, DataReader reader) {
	optionTypesRegistry.put(optionsType.getCanonicalName(), reader);
    }

    public void registerExtension(String extension, DataReader reader) {
	extensionsRegistry.put(extension, reader);
    }

    public void registerMimeType(String mimeType, DataReader reader) {
	mimeTypesRegistry.put(mimeType, reader);
    }

    @SuppressWarnings("unchecked")
    public  DataReader getReaderForOptions(T options) {
	return (DataReader) optionTypesRegistry.get(options.getClass().getCanonicalName());
    }

    public DataReader getReaderForExtension(String extension) {
	return extensionsRegistry.get(extension);
    }

    public DataReader getReaderForMimeType(String mimeType) {
	return mimeTypesRegistry.get(mimeType);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy