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