1 package org.simantics.spreadsheet.graph.formula;
3 import org.simantics.spreadsheet.graph.CellFormulaFunction;
4 import org.simantics.spreadsheet.graph.CellValueVisitor;
5 import org.simantics.spreadsheet.graph.SpreadsheetGraphUtils;
6 import org.simantics.spreadsheet.graph.parser.ast.AstArgList;
8 public class AndFormulaFunction implements CellFormulaFunction<Object> {
11 public Object evaluate(CellValueVisitor visitor, AstArgList args) {
12 if (args.values.size() == 0)
13 throw new IllegalStateException();
14 Boolean finalResult = Boolean.TRUE;
15 for (int i = 0; i < args.values.size(); i++) {
16 Object res = (args.values.get(i).accept(visitor));
17 FormulaError2 err = FormulaError2.forObject(res);
18 if(err!=null) return err.getString();
20 if ((res instanceof Boolean && !((Boolean)res)) || !SpreadsheetGraphUtils.asBoolean(res))
21 finalResult = Boolean.FALSE;