
package de.ivu.elect.exchange.csv;

import org.jsefa.csv.CsvIOFactory;
import org.jsefa.csv.config.CsvConfiguration;

import de.ivu.elect.business.exchange.control.FileKonfiguration;
import de.ivu.jsefa.IvuCsvIOFactory;

public class ElectCsvIOFactory {

  private ElectCsvIOFactory() {
    super();
  }

  public static CsvIOFactory create(Class< ? > clazz) {
    return IvuCsvIOFactory.createIvuCsvIOFactory(clazz);
  }

  public static CsvIOFactory create(FileKonfiguration fileKonfiguration, Class< ? > clazz) {
    return create(asCsvDescriptor(fileKonfiguration), clazz);
  }

  public static CsvIOFactory create(CsvDescriptor csvDescriptor, Class< ? > clazz) {
    return create(asCsvConfiguration(csvDescriptor), clazz);
  }

  public static CsvIOFactory create(CsvConfiguration csvConfiguration, Class< ? > clazz) {
    return IvuCsvIOFactory.createIvuCsvIOFactory(csvConfiguration, clazz);
  }

  private static CsvDescriptor asCsvDescriptor(FileKonfiguration fileKonfiguration) {
    return CsvDescriptor.forFileKonfiguration(fileKonfiguration);
  }

  private static CsvConfiguration asCsvConfiguration(CsvDescriptor csvDescriptor) {
    return ElectCsvConfigurationFactory.create(csvDescriptor);
  }
}
