@Override @SuppressWarnings("unchecked") public Range setCellValue(final int rowIndex, final int columnIndex, final GridCellValue<?> value) { return doSetCell(rowIndex, columnIndex, (pair) -> { final Optional<BaseGridCell> cell = Optional.ofNullable((BaseGridCell) getCell(pair.getKey(), pair.getValue())); final BaseGridCell c = cell.orElse(new BaseGridCell<>(value)); c.setValue(value); return c; }); }
@Override @SuppressWarnings("unchecked") public Range setCellValue(final int rowIndex, final int columnIndex, final GridCellValue<?> value) { return doSetCell(rowIndex, columnIndex, (pair) -> { final Optional<BaseGridCell> cell = Optional.ofNullable((BaseGridCell) getCell(pair.getKey(), pair.getValue())); final BaseGridCell c = cell.orElse(new BaseGridCell<>(value)); c.setValue(value); return c; }); }
@Test public void testSetCellValueWhenNoExistingGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(BaseGridCell.class); }
@Test public void testSetCellValueWhenNoExistingGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(BaseGridCell.class); }
@Test public void testSetCellValueWhenExistingBaseGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(""))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(BaseGridCell.class); }
@Test public void testSetCellValueWhenExistingCustomGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new CustomGridCell<>(new BaseGridCellValue<>("hello"))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(CustomGridCell.class); }
@Test public void testSetCellValueWhenExistingBaseGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(""))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(BaseGridCell.class); }
@Test public void testSetCellValueWhenExistingCustomGridCell() { final BaseGridColumn<String> column = new BaseGridColumn<>(header, columnRenderer, 25.0); baseGridData.insertColumn(0, column); baseGridData.appendRow(new BaseGridRow()); baseGridData.setCell(0, 0, () -> new CustomGridCell<>(new BaseGridCellValue<>("hello"))); baseGridData.setCellValue(0, 0, new BaseGridCellValue<>("hello")); assertThat(baseGridData.getCell(0, 0).getValue().getValue()).isEqualTo("hello"); assertThat(baseGridData.getCell(0, 0)).isInstanceOf(CustomGridCell.class); }