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

br.com.objectos.jabuticava.serasa.relato.factoring.TotalPagamentoParser Maven / Gradle / Ivy

The newest version!
package br.com.objectos.jabuticava.serasa.relato.factoring;

import br.com.objectos.way.io.flat.FlatFileReader;
import br.com.objectos.way.io.flat.Record;
import br.com.objectos.way.io.flat.RecordMatcher;
import br.com.objectos.way.io.flat.RecordParseException;
import br.com.objectos.way.io.flat.RecordParser;
import javax.annotation.Generated;

@Generated("br.com.objectos.way.io.flat.FlatRecordPlugin")
final class TotalPagamentoParser implements RecordMatcher, RecordParser {
  private static final TotalPagamentoParser INSTANCE = new TotalPagamentoParser();

  private static final String id = "05";

  private static final String brancos = "                                                                                                                                                                  ";

  private TotalPagamentoParser() {
  }

  public static RecordParser get() {
    return INSTANCE;
  }

  public static RecordMatcher getMatcher() {
    return INSTANCE;
  }

  @Override
  public boolean matches(String line) {
    return line != null ? line.startsWith("05") : false;
  }

  @Override
  public TotalPagamento parse(FlatFileReader file) throws RecordParseException {
    Record record = file.recordReader()
        .fixed(id)
        .integer(8)
        .decimal(18, 2)
        .fixed(brancos)
        .read();

    if (!record.valid()) {
      throw record.parseException();
    }

    return new TotalPagamentoBuilderPojo()
        .quantidade(record.intValue())
        .soma(record.doubleValue())
        .build();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy