
package de.ivu.elect.exchange.csv.converter;

import org.jsefa.common.converter.SimpleTypeConverterConfiguration;

import de.ivu.elect.business.exchange.boundary.ExchangeValueDecorators;

public class ElectCsvStringConverter extends AbstractElectCsvStringConverter {

  private final ExchangeValueDecorators exchangeValueDecorators;

  protected ElectCsvStringConverter(SimpleTypeConverterConfiguration configuration) {
    super(configuration);

    this.exchangeValueDecorators = new ExchangeValueDecorators();
  }

  public static ElectCsvStringConverter create(SimpleTypeConverterConfiguration configuration) {
    return new ElectCsvStringConverter(configuration);
  }

  @Override
  public String toString(Object value) {
    String result = super.toString(value);

    if (result != null) {
      result = exchangeValueDecorators.apply(result); // ELECT-6722, ELECT-5329
    }

    return result;
  }
}
