@Override public void update(Cell changed) { if (!spreadSheet.getModified().contains(this)) { spreadSheet.getModified().add(this); setValue(new vInvalid(expression)); for (Cell cell : referThis) cell.update(this); } }
@Override public int hashCode() { int result = spreadSheet != null ? spreadSheet.hashCode() : 0; result = 31 * result + (location != null ? location.hashCode() : 0); result = 31 * result + (expression != null ? expression.hashCode() : 0); result = 31 * result + (isModified ? 1 : 0); return result; }
public void setExpression(String expression) { if (expression.startsWith("=")) expression = expression.replaceFirst("=", ""); for (CellImpl cell : thisRefer) { cell.referThis.remove(this); } this.thisRefer.clear(); this.expression = expression; setValue(new vInvalid(expression)); spreadSheet.getModified().add(this); for (Location location : SpreadsheetImpl.getReferredLocation(expression)) { CellImpl cell = spreadSheet.InsertCellIfNotExistAt(location); thisRefer.add(cell); cell.referThis.add(this); } for (Cell cell : referThis) cell.update(this); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CellImpl cell = (CellImpl) o; if (isModified != cell.isModified) return false; if (spreadSheet != null ? !spreadSheet.equals(cell.spreadSheet) : cell.spreadSheet != null) return false; if (location != null ? !location.equals(cell.location) : cell.location != null) return false; if (expression != null ? !expression.equals(cell.expression) : cell.expression != null) return false; return true; }