// Path: src/main/java/br/com/tecsinapse/dataio/util/Constants.java
// public static final String MIME_XLS = "application/vnd.ms-excel";
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/Constants.java
// public static final String MIME_XLSM = "application/vnd.ms-excel.sheet.macroEnabled.12";
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/Constants.java
// public static final String MIME_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/Constants.java
// public static final String MSG_IGNORED = "Ignored";
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/ExporterDateUtils.java
// @Slf4j
// @UtilityClass
// public final class ExporterDateUtils {
// 
//     private static final Date DATETIME_BIGBANG_PLUS_24H = new Date(-2208977612000L);
//     private static final String TIME_ISO_FORMAT = "HH:mm:ss";
//     private static final String DATE_ISO_FORMAT = "yyyy-MM-dd";
//     private static final String DATETIME_ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
//     private static final String DATETIME_FILE_FORMAT = "yyyy-MM-dd_HH-mm";
// 
//     public static DateType getDateType(Date date) {
//         if (date == null) {
//             return DateType.NO_DATE;
//         }
//         if (date instanceof java.sql.Date) {
//             return DateType.DATE;
//         }
//         if (DATETIME_BIGBANG_PLUS_24H.after(date)) {
//             return DateType.TIME;
//         }
// 
//         if (isTimeFieldEqualZero(date)) {
//             return DateType.DATE;
//         }
//         return DateType.DATETIME;
//     }
// 
//     private static boolean isTimeFieldEqualZero(Date date) {
//         Calendar calendar  = Calendar.getInstance();
//         calendar.setTime(date);
//         return calendar.get(Calendar.SECOND) == 0 && calendar.get(Calendar.MINUTE) == 0 && calendar.get(Calendar.HOUR) == 0;
//     }
// 
//     public static String formatWithIsoByDateType(Date date) {
//         DateType dateType = getDateType(date);
//         if (dateType == DateType.NO_DATE) {
//             return null;
//         }
//         if (dateType == DateType.TIME) {
//             return formatDate(TIME_ISO_FORMAT, date);
//         }
//         if (dateType == DateType.DATE) {
//             return formatDate(DATE_ISO_FORMAT, date);
//         }
//         return formatDate(DATETIME_ISO_FORMAT, date);
//     }
// 
//     public static String formatAsFileDateTime(Date date) {
//         return formatDate(DATETIME_FILE_FORMAT, date);
//     }
// 
//     public static Date parseDate(String strDate) {
//         if (strDate == null) {
//             return null;
//         }
//         try {
//             return new SimpleDateFormat(DATETIME_ISO_FORMAT).parse(strDate);
//         } catch (ParseException e) {
//             log.error("Parse date '{}' error.", strDate, e);
//             return null;
//         }
//     }
// 
//     public enum DateType {
//         TIME, DATE, DATETIME, NO_DATE
//     }
// 
//     private static String formatDate(String format, Date date) {
//         return new SimpleDateFormat(format).format(date);
//     }
// 
// }


import static br.com.tecsinapse.dataio.util.Constants.MIME_XLS;
import static br.com.tecsinapse.dataio.util.Constants.MIME_XLSM;
import static br.com.tecsinapse.dataio.util.Constants.MIME_XLSX;
import static br.com.tecsinapse.dataio.util.Constants.MSG_IGNORED;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import lombok.AllArgsConstructor;
import lombok.Getter;
import br.com.tecsinapse.dataio.util.ExporterDateUtils;
    SXLSX("MS Excel file (.xlsx)", MIME_XLSX, ".xlsx") {
        @Override
        public Workbook buildWorkbook(InputStream inputStream) throws IOException {
            return new SXSSFWorkbook(new XSSFWorkbook(inputStream));
        }
    },
    XLSM("MS Excel file (.xlsm)", MIME_XLSM, ".xlsm") {
        @Override
        public Workbook buildWorkbook(InputStream inputStream) throws IOException {
            return XLSX.buildWorkbook(inputStream);
        }
    },
    CSV("CSV file", "text/plain", ".csv"),
    TXT("Text file", "text/plain", ".txt"),
    ZIP("Zip file", "application/zip", ".zip");

    private final String description;
    private final String mimeType;
    private final String extension;

    public static FileType getFileType(String filename) {
        for (FileType fileType : values()) {
            if (filename.toLowerCase().endsWith(fileType.getExtension().toLowerCase())) {
                return fileType;
            }
        }
        return TXT;
    }

    public Workbook buildWorkbook(InputStream inputStream) throws IOException {
// Path: src/main/java/br/com/tecsinapse/dataio/util/Constants.java
// public static final String MIME_XLS = "application/vnd.ms-excel";
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/Constants.java
// public static final String MIME_XLSM = "application/vnd.ms-excel.sheet.macroEnabled.12";
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/Constants.java
// public static final String MIME_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/Constants.java
// public static final String MSG_IGNORED = "Ignored";
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/ExporterDateUtils.java
// @Slf4j
// @UtilityClass
// public final class ExporterDateUtils {
// 
//     private static final Date DATETIME_BIGBANG_PLUS_24H = new Date(-2208977612000L);
//     private static final String TIME_ISO_FORMAT = "HH:mm:ss";
//     private static final String DATE_ISO_FORMAT = "yyyy-MM-dd";
//     private static final String DATETIME_ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
//     private static final String DATETIME_FILE_FORMAT = "yyyy-MM-dd_HH-mm";
// 
//     public static DateType getDateType(Date date) {
//         if (date == null) {
//             return DateType.NO_DATE;
//         }
//         if (date instanceof java.sql.Date) {
//             return DateType.DATE;
//         }
//         if (DATETIME_BIGBANG_PLUS_24H.after(date)) {
//             return DateType.TIME;
//         }
// 
//         if (isTimeFieldEqualZero(date)) {
//             return DateType.DATE;
//         }
//         return DateType.DATETIME;
//     }
// 
//     private static boolean isTimeFieldEqualZero(Date date) {
//         Calendar calendar  = Calendar.getInstance();
//         calendar.setTime(date);
//         return calendar.get(Calendar.SECOND) == 0 && calendar.get(Calendar.MINUTE) == 0 && calendar.get(Calendar.HOUR) == 0;
//     }
// 
//     public static String formatWithIsoByDateType(Date date) {
//         DateType dateType = getDateType(date);
//         if (dateType == DateType.NO_DATE) {
//             return null;
//         }
//         if (dateType == DateType.TIME) {
//             return formatDate(TIME_ISO_FORMAT, date);
//         }
//         if (dateType == DateType.DATE) {
//             return formatDate(DATE_ISO_FORMAT, date);
//         }
//         return formatDate(DATETIME_ISO_FORMAT, date);
//     }
// 
//     public static String formatAsFileDateTime(Date date) {
//         return formatDate(DATETIME_FILE_FORMAT, date);
//     }
// 
//     public static Date parseDate(String strDate) {
//         if (strDate == null) {
//             return null;
//         }
//         try {
//             return new SimpleDateFormat(DATETIME_ISO_FORMAT).parse(strDate);
//         } catch (ParseException e) {
//             log.error("Parse date '{}' error.", strDate, e);
//             return null;
//         }
//     }
// 
//     public enum DateType {
//         TIME, DATE, DATETIME, NO_DATE
//     }
// 
//     private static String formatDate(String format, Date date) {
//         return new SimpleDateFormat(format).format(date);
//     }
// 
// }


// Path: src/main/java/br/com/tecsinapse/dataio/type/FileType.java
import static br.com.tecsinapse.dataio.util.Constants.MIME_XLS;
import static br.com.tecsinapse.dataio.util.Constants.MIME_XLSM;
import static br.com.tecsinapse.dataio.util.Constants.MIME_XLSX;
import static br.com.tecsinapse.dataio.util.Constants.MSG_IGNORED;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import lombok.AllArgsConstructor;
import lombok.Getter;
import br.com.tecsinapse.dataio.util.ExporterDateUtils;

    SXLSX("MS Excel file (.xlsx)", MIME_XLSX, ".xlsx") {
        @Override
        public Workbook buildWorkbook(InputStream inputStream) throws IOException {
            return new SXSSFWorkbook(new XSSFWorkbook(inputStream));
        }
    },
    XLSM("MS Excel file (.xlsm)", MIME_XLSM, ".xlsm") {
        @Override
        public Workbook buildWorkbook(InputStream inputStream) throws IOException {
            return XLSX.buildWorkbook(inputStream);
        }
    },
    CSV("CSV file", "text/plain", ".csv"),
    TXT("Text file", "text/plain", ".txt"),
    ZIP("Zip file", "application/zip", ".zip");

    private final String description;
    private final String mimeType;
    private final String extension;

    public static FileType getFileType(String filename) {
        for (FileType fileType : values()) {
            if (filename.toLowerCase().endsWith(fileType.getExtension().toLowerCase())) {
                return fileType;
            }
        }
        return TXT;
    }

    public Workbook buildWorkbook(InputStream inputStream) throws IOException {
        throw new UnsupportedOperationException(MSG_IGNORED);