]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/SpreadsheetFormula.java b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/SpreadsheetFormula.java
new file mode 100644 (file)
index 0000000..6933356
--- /dev/null
@@ -0,0 +1,54 @@
+package org.simantics.spreadsheet.solver;
+
+import java.io.Serializable;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.spreadsheet.solver.formula.parser.ast.AstValue;
+
+public class SpreadsheetFormula implements Serializable {
+
+    public static Binding BINDING = Bindings.getBindingUnchecked(SpreadsheetFormula.class);
+    
+    private static final long serialVersionUID = -3369406031425959191L;
+
+    public AstValue value;
+    public String expression;
+    public Object result;
+
+    public SpreadsheetFormula(AstValue value, String expression) {
+        this.value = value;
+        this.expression = expression;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((expression == null) ? 0 : expression.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SpreadsheetFormula other = (SpreadsheetFormula) obj;
+        if (expression == null) {
+            if (other.expression != null)
+                return false;
+        } else if (!expression.equals(other.expression))
+            return false;
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + " [" + expression +" => " + result != null ? result.toString() : "" + "]";
+    }
+
+}