]> gerrit.simantics Code Review - simantics/platform.git/blob
891992c7d23c93f588a6ed7f61247cb373a643bd
[simantics/platform.git] /
1 package org.simantics.spreadsheet.graph.formula;
2
3 import org.simantics.spreadsheet.graph.CellFormulaFunction;
4 import org.simantics.spreadsheet.graph.CellValueVisitor;
5 import org.simantics.spreadsheet.graph.parser.ast.AstArgList;
6
7 public class IfErrorFormulaFunction implements CellFormulaFunction<Object> {
8         
9         @Override
10     public Object evaluate(CellValueVisitor visitor, AstArgList args) {
11                 
12         if (args.values.size() != 2) throw new IllegalStateException();
13         
14         Object condition = args.values.get(0).accept(visitor);
15         FormulaError2 error = FormulaError2.forObject(condition);
16         if(error!=null) return error.getString();
17         else return condition;
18     }
19 }