name:
src/main/java/io/protobase/f7/spreadsheet/Worksheet.java
-rw-r--r--
1242
1package io.protobase.f7.spreadsheet;
2
3import com.google.common.base.MoreObjects;
4import io.protobase.f7.models.BaseObject;
5import io.protobase.f7.models.Cell;
6import io.protobase.f7.models.ColumnRowKey;
7import io.protobase.f7.models.Grid;
8
9import java.util.Objects;
10
11public class Worksheet extends BaseObject {
12 private String name;
13 private Grid<Cell> cells;
14
15 public Worksheet(String name, Grid<Cell> cells) {
16 this.name = name;
17 this.cells = cells;
18 }
19
20 public String getName() {
21 return name;
22 }
23
24 public Grid<Cell> getCells() {
25 return cells;
26 }
27
28 public Cell getCell(ColumnRowKey key) {
29 return cells.get(key);
30 }
31
32 public void setCell(ColumnRowKey key, Cell cell) {
33 cells.set(key, cell);
34 }
35
36 public void setCellComputedValue(ColumnRowKey key, Object computedValue) {
37 Cell cell = getCell(key);
38 if (Objects.nonNull(cell)) {
39 cell.setComputedValue(computedValue);
40 cells.set(key, cell);
41 }
42 }
43
44 @Override
45 public Object[] significantAttributes() {
46 return new Object[]{
47 name,
48 cells
49 };
50 }
51
52 @Override
53 public String toString() {
54 return MoreObjects.toStringHelper(this)
55 .add("name", name)
56 .add("cells", cells)
57 .toString();
58 }
59}