// Path: src/main/java/br/com/tecsinapse/dataio/converter/Converter.java
// public interface Converter<F, T> {
//     T apply(F input);
//     T apply(String input);
// }
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/FixedLengthFileUtil.java
// @UtilityClass
// public final class FixedLengthFileUtil {
// 
//     public static List<String> getLines(InputStream inputStream, boolean ignoreFirstLine, Charset charset) throws IOException {
//         return getLines(inputStream, ignoreFirstLine, 0, null, charset);
//     }
// 
//     private static List<String> getLines(InputStream inputStream, boolean ignoreFirstLine, int afterLine, String eofCharacter, Charset charset) throws IOException {
//         return getLines(inputStream, ignoreFirstLine, afterLine, 0, eofCharacter, charset);
//     }
// 
//     public static List<String> getLines(InputStream inputStream, boolean ignoreFirstLine, int afterLine, int ignoreLastLines, String eofCharacter, Charset charset) throws IOException {
//         List<String> lines = new ArrayList<>();
//         try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, charset))) {
//             String line;
// 
//             afterLine += (ignoreFirstLine ? 1 : 0);
// 
//             for (int i = 0; i < afterLine; i++) {
//                 line = br.readLine();
//             }
// 
//             line = br.readLine();
//             while (!isEof(line, eofCharacter)) {
//                 if (!line.trim().isEmpty()) {
//                     lines.add(line);
//                 }
//                 line = br.readLine();
//             }
//         }
// 
//         if (ignoreLastLines > 0 && lines.size() >= ignoreLastLines) {
//             lines = lines.subList(0, lines.size() - ignoreLastLines);
//         }
// 
//         return lines;
//     }
// 
//     private static boolean isEof(String line, String eofCharacter) {
//         return line == null || (eofCharacter != null && line.contains(eofCharacter));
//     }
// 
// }


import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.reflections.ReflectionUtils;
import com.google.common.collect.Iterables;
import com.google.common.primitives.Ints;
import lombok.AllArgsConstructor;
import lombok.Getter;
import br.com.tecsinapse.dataio.annotation.FixedLengthColumn;
import br.com.tecsinapse.dataio.annotation.LineFixedLengthFile;
import br.com.tecsinapse.dataio.converter.Converter;
import br.com.tecsinapse.dataio.util.FixedLengthFileUtil;
        return this;
    }

    public FixedLengthFileParser<T> withRemoveDuplicatedSpaces(boolean removeDuplicatedSpaces) {
        this.removeDuplicatedSpaces = removeDuplicatedSpaces;
        return this;
    }

    public FixedLengthFileParser<T> withEofCharacter(String eof) {
        this.eof = eof;
        return this;
    }

    public FixedLengthFileParser<T> withIgnoreLastLines(int linesToIgnore) {
        this.ignoreLastLines = linesToIgnore;
        return this;
    }

    public FixedLengthFileParser<T> withIgnoreColumnLengthError(boolean ignoreColumnLengthError) {
        this.ignoreColumnLengthError = ignoreColumnLengthError;
        return this;
    }

    public List<T> parse(File file) throws IOException, ReflectiveOperationException {
        return parse(new FileInputStream(file));
    }

    public List<T> parse(InputStream inputStream) throws IOException, ReflectiveOperationException {

        final List<T> list = new ArrayList<>();
// Path: src/main/java/br/com/tecsinapse/dataio/converter/Converter.java
// public interface Converter<F, T> {
//     T apply(F input);
//     T apply(String input);
// }
// 
// Path: src/main/java/br/com/tecsinapse/dataio/util/FixedLengthFileUtil.java
// @UtilityClass
// public final class FixedLengthFileUtil {
// 
//     public static List<String> getLines(InputStream inputStream, boolean ignoreFirstLine, Charset charset) throws IOException {
//         return getLines(inputStream, ignoreFirstLine, 0, null, charset);
//     }
// 
//     private static List<String> getLines(InputStream inputStream, boolean ignoreFirstLine, int afterLine, String eofCharacter, Charset charset) throws IOException {
//         return getLines(inputStream, ignoreFirstLine, afterLine, 0, eofCharacter, charset);
//     }
// 
//     public static List<String> getLines(InputStream inputStream, boolean ignoreFirstLine, int afterLine, int ignoreLastLines, String eofCharacter, Charset charset) throws IOException {
//         List<String> lines = new ArrayList<>();
//         try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, charset))) {
//             String line;
// 
//             afterLine += (ignoreFirstLine ? 1 : 0);
// 
//             for (int i = 0; i < afterLine; i++) {
//                 line = br.readLine();
//             }
// 
//             line = br.readLine();
//             while (!isEof(line, eofCharacter)) {
//                 if (!line.trim().isEmpty()) {
//                     lines.add(line);
//                 }
//                 line = br.readLine();
//             }
//         }
// 
//         if (ignoreLastLines > 0 && lines.size() >= ignoreLastLines) {
//             lines = lines.subList(0, lines.size() - ignoreLastLines);
//         }
// 
//         return lines;
//     }
// 
//     private static boolean isEof(String line, String eofCharacter) {
//         return line == null || (eofCharacter != null && line.contains(eofCharacter));
//     }
// 
// }


// Path: src/main/java/br/com/tecsinapse/dataio/importer/parser/FixedLengthFileParser.java
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.reflections.ReflectionUtils;
import com.google.common.collect.Iterables;
import com.google.common.primitives.Ints;
import lombok.AllArgsConstructor;
import lombok.Getter;
import br.com.tecsinapse.dataio.annotation.FixedLengthColumn;
import br.com.tecsinapse.dataio.annotation.LineFixedLengthFile;
import br.com.tecsinapse.dataio.converter.Converter;
import br.com.tecsinapse.dataio.util.FixedLengthFileUtil;

        return this;
    }

    public FixedLengthFileParser<T> withRemoveDuplicatedSpaces(boolean removeDuplicatedSpaces) {
        this.removeDuplicatedSpaces = removeDuplicatedSpaces;
        return this;
    }

    public FixedLengthFileParser<T> withEofCharacter(String eof) {
        this.eof = eof;
        return this;
    }

    public FixedLengthFileParser<T> withIgnoreLastLines(int linesToIgnore) {
        this.ignoreLastLines = linesToIgnore;
        return this;
    }

    public FixedLengthFileParser<T> withIgnoreColumnLengthError(boolean ignoreColumnLengthError) {
        this.ignoreColumnLengthError = ignoreColumnLengthError;
        return this;
    }

    public List<T> parse(File file) throws IOException, ReflectiveOperationException {
        return parse(new FileInputStream(file));
    }

    public List<T> parse(InputStream inputStream) throws IOException, ReflectiveOperationException {

        final List<T> list = new ArrayList<>();
        final List<String> lines = FixedLengthFileUtil.getLines(inputStream, ignoreFirstLine, afterLine, ignoreLastLines, eof, charset);