Class StringOneLineHeaderExcelTableToBeanReader<T extends StringExcelTableBean>

All Implemented Interfaces:
IfDataTypeStringExcelTable, IfExcelTable<String>, IfFormatOneLineHeaderExcelTable<String>, IfDataTypeStringExcelTableReader, IfExcelTableReader<String>, IfFormatOneLineHeaderExcelTableReader<String>

public class StringOneLineHeaderExcelTableToBeanReader<T extends StringExcelTableBean> extends StringOneLineHeaderExcelTableReader
Stores the excel table data into a bean.
  • Constructor Details

    • StringOneLineHeaderExcelTableToBeanReader

      public StringOneLineHeaderExcelTableToBeanReader(Class<?> beanClass, @RequireNonnull String sheetName, @RequireNonnull String[] headerLabels, Integer tableStartRowNumber, int tableStartColumnNumber, Integer tableRowSize, T... parameterClass)
      Constructs a new instance. the obtained value from an empty cell is null.

      In most cases null is recommended because Bean Validation annotations (like Max) returns valid for null, but invalid for "".

      Parameters:
      beanClass - the class of the generic parameter T is hard to obtain especially the constructor of this class is called directly with setting a class instead of T, like List<Foo> list = new StringOneLineHeaderExcelTableToBeanReader<Foo>(...).
      See here.
    • StringOneLineHeaderExcelTableToBeanReader

      public StringOneLineHeaderExcelTableToBeanReader(Class<?> beanClass, @RequireNonnull String sheetName, @RequireNonnull String[] headerLabels, Integer tableStartRowNumber, int tableStartColumnNumber, Integer tableRowSize, @Nonnull NoDataString noDataString)
      Constructs a new instance with the obtained value from an empty cell.
      Parameters:
      beanClass - the class of the generic parameter T is hard to obtain especially the constructor of this class is called directly with setting a class instead of T, like List<Foo> list = new StringOneLineHeaderExcelTableToBeanReader<Foo>(...).
      See here.
      noDataString - the obtained value from an empty cell. null or "".
  • Method Details

    • readToBean

      public List<T> readToBean(String filePath) throws jp.ecuacion.lib.core.exception.checked.AppException, org.apache.poi.EncryptedDocumentException, IOException
      Obtains excel table in the form of List<PoiStringTableBean> and validate obtained values..
      Parameters:
      filePath - excelPath
      Returns:
      the list of PoiStringTableBean.
      Throws:
      jp.ecuacion.lib.core.exception.checked.AppException - AppException
      org.apache.poi.EncryptedDocumentException - EncryptedDocumentException
      IOException - IOException
    • excelTableToBeanList

      protected List<T> excelTableToBeanList(String filePath) throws jp.ecuacion.lib.core.exception.checked.AppException, IOException
      Obtains excel table in the form of List<PoiStringTableBean>.

      Since read method contains validation function, you may want to test the validations. Although you don't want to prepare excel files to test each case.
      When that's the case, you can skip the preparation of excel files by overriding this method and return list you want to test.

      Throws:
      jp.ecuacion.lib.core.exception.checked.AppException
      IOException