]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/SpreadsheetFormula.java
Adopt spreadsheet changes made in Balas development
[simantics/platform.git] / bundles / org.simantics.spreadsheet / src / org / simantics / spreadsheet / solver / SpreadsheetFormula.java
1 package org.simantics.spreadsheet.solver;
2
3 import java.io.Serializable;
4
5 import org.simantics.databoard.Bindings;
6 import org.simantics.databoard.binding.Binding;
7 import org.simantics.spreadsheet.solver.formula.parser.ast.AstValue;
8
9 public class SpreadsheetFormula implements Serializable {
10
11     public static Binding BINDING = Bindings.getBindingUnchecked(SpreadsheetFormula.class);
12     
13     private static final long serialVersionUID = -3369406031425959191L;
14
15     public AstValue value;
16     public String expression;
17     public Object result;
18
19     public SpreadsheetFormula(AstValue value, String expression) {
20         this.value = value;
21         this.expression = expression;
22     }
23
24     @Override
25     public int hashCode() {
26         final int prime = 31;
27         int result = 1;
28         result = prime * result + ((expression == null) ? 0 : expression.hashCode());
29         return result;
30     }
31
32     @Override
33     public boolean equals(Object obj) {
34         if (this == obj)
35             return true;
36         if (obj == null)
37             return false;
38         if (getClass() != obj.getClass())
39             return false;
40         SpreadsheetFormula other = (SpreadsheetFormula) obj;
41         if (expression == null) {
42             if (other.expression != null)
43                 return false;
44         } else if (!expression.equals(other.expression))
45             return false;
46         return true;
47     }
48
49     @Override
50     public String toString() {
51         return getClass().getSimpleName() + " [" + expression +" => " + result != null ? result.toString() : "" + "]";
52     }
53
54 }