private Cell addCell(int colIndex, int rowIndex, int colNum, int rowNum, String colName, String rowName) { Cell cell = (allCells.size() != 0) ? (Cell) first(allCells, c -> c.columnNum() == colNum && c.rowNum() == rowNum) : null; if (cell != null) return cell.updateData(colName, rowName); cell = new Cell(colIndex, rowIndex, colNum, rowNum, colName, rowName, cellLocatorTemplate, this); cell.setParent(this); if (cache) allCells.add(cell); return cell; }
private void setRowField(R row, Field[] fields, String fieldName, ICell cell) { setField(row, fields, fieldName, field -> { Class clazz = field.getType(); if (clazz == null) return null; IBaseElement value; try { value = cell.get(clazz); } catch (Exception e) { throw exception("Can't Instantiate row element: " + fieldName); } return value; }); }
private E rowToEntity(MapArray<String, ICell> row) { E entity = newEntity(entityClass); if (row == null) return entity; Field[] fields = entity.getClass().getFields(); row.pairs.forEach(entry -> setEntityField(entity, fields, entry.key, entry.value.getText())); return entity; }
private List<ICell> contains(Collection<ICell> list, String value) { return new ArrayList<>(where(list, cell -> cell.getValue().contains(value))); } private List<ICell> matches(Collection<ICell> list, String regex) {
public MapArray<String, ICell> cellsToRow(Collection<ICell> cells) { return new MapArray<>(cells, cell -> headers().get(cell.columnNum() - 1), cell -> cell); }
public MapArray<String, ICell> cellsToColumn(Collection<ICell> cells) { return new MapArray<>(cells, cell -> headers().get(cell.rowNum() - 1), cell -> cell); }
private List<ICell> contains(Collection<ICell> list, String value) { return new ArrayList<>(where(list, cell -> cell.getValue().contains(value))); } private List<ICell> matches(Collection<ICell> list, String regex) {
public MapArray<String, ICell> cellsToRow(Collection<ICell> cells) { return new MapArray<>(cells, cell -> headers().get(cell.columnNum() - 1), cell -> cell); }
public MapArray<String, ICell> cellsToColumn(Collection<ICell> cells) { return new MapArray<>(cells, cell -> headers().get(cell.rowNum() - 1), cell -> cell); }
private List<ICell> contains(Collection<ICell> list, String value) { return new ArrayList<>(where(list, cell -> cell.getValue().contains(value))); } private List<ICell> matches(Collection<ICell> list, String regex) {
private Cell addCell(int colIndex, int rowIndex, int colNum, int rowNum, String colName, String rowName) { Cell cell = allCells.size() != 0 ? (Cell) first(allCells, c -> c.columnNum() == colNum && c.rowNum() == rowNum) : null; if (cell != null) return cell.updateData(colName, rowName); cell = new Cell(colIndex, rowIndex, colNum, rowNum, colName, rowName, this); cell.setParent(this); if (cache) allCells.add(cell); return cell; }
public MapArray<String, ICell> cellsToRow(Collection<ICell> cells) { return new MapArray<>(cells, cell -> headers().get(cell.columnNum() - 1), cell -> cell); }
public MapArray<String, ICell> cellsToColumn(Collection<ICell> cells) { return new MapArray<>(cells, cell -> headers().get(cell.rowNum() - 1), cell -> cell); }
private E rowToEntity(MapArray<String, ICell> row) { E entity = newEntity(entityClass); if (row == null) return entity; Field[] fields = entity.getClass().getFields(); row.pairs.forEach(entry -> setEntityField(entity, fields, entry.key, entry.value.getText())); return entity; }
private void setRowField(R row, Field[] fields, String fieldName, ICell cell) { setField(row, fields, fieldName, field -> { Class clazz = field.getType(); if (clazz == null) return null; IBaseElement value; try { value = cell.get(clazz); } catch (Exception e) { throw exception("Can't Instantiate row element: " + fieldName); } return value; }); }
private List<ICell> matches(Collection<ICell> list, String regex) { return new ArrayList<>(where(list, cell -> cell.getValue().matches(regex))); }
private Cell addCell(int colIndex, int rowIndex, int colNum, int rowNum, String colName, String rowName) { Cell cell = allCells.size() != 0 ? (Cell) first(allCells, c -> c.columnNum() == colNum && c.rowNum() == rowNum) : null; if (cell != null) return cell.updateData(colName, rowName); cell = new Cell(colIndex, rowIndex, colNum, rowNum, colName, rowName, this); cell.setParent(this); if (cache) allCells.add(cell); return cell; }
public MapArray<String, ICell> columnMatch(String regEx, Row row) { ICell columnCell = cellMatch(regEx, row); if (columnCell == null) { logger.info(format("Can't find any cells in row %s that matches regex %s", row, regEx)); return null; } return columns().getColumn(columnCell.columnNum()); }
public MapArray<String, ICell> rowContains(String value, Column column) { ICell rowCell = cellContains(value, column); if (rowCell == null) { logger.info(format("Can't find any cells in column %s that contains value %s", column, value)); return null; } return rows().getRow(rowCell.rowNum()); } public MapArray<String, ICell> rowMatch(String regEx, Column column) {
private E rowToEntity(MapArray<String, ICell> row) { E entity = newEntity(); if (row == null){ return entity; } Field[] fields = entity.getClass().getFields(); row.pairs .forEach(entry -> setEntityField(entity, fields, entry.key, entry.value.getText())); return entity; }