package com.engine.htsc.financialadjustment.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import weaver.workflow.logging.Logger;
import weaver.workflow.logging.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
public class ExcelDataListener<T> extends AnalysisEventListener<T> {

  private final Logger logger = LoggerFactory.getLogger();
  List<T> list = new ArrayList<>();

  /**
   * read line2
   */
  @Override
  public void invoke(T t, AnalysisContext analysisContext) {
    logger.info("excel data :" + t);
    list.add(t);
  }

  /**
   * finish reading all line, after do
   */
  @Override
  public void doAfterAllAnalysed(AnalysisContext analysisContext) {
    logger.info("Finish extracting excel data, list: " + list);
  }

  public List<T> getList() {
    return list;
  }

  public void setList(List<T> list) {
    this.list = list;
  }
}
