Search in sources :

Example 1 with ArgumentException

use of org.activityinfo.model.formula.diagnostic.ArgumentException in project activityinfo by bedatadriven.

the class IfFunction method resolveResultType.

@Override
public FieldType resolveResultType(List<FieldType> argumentTypes) {
    checkArity(argumentTypes, 3);
    FieldType conditionType = argumentTypes.get(0);
    if (!(conditionType instanceof BooleanType)) {
        throw new ArgumentException(0, "Expected TRUE/FALSE value");
    }
    FieldType trueType = argumentTypes.get(1);
    FieldType falseType = argumentTypes.get(2);
    if (trueType.getTypeClass() != falseType.getTypeClass()) {
        throw new ArgumentException(2, "Must have the same type as the TRUE argument.");
    }
    return trueType;
}
Also used : BooleanType(org.activityinfo.model.type.primitive.BooleanType) ArgumentException(org.activityinfo.model.formula.diagnostic.ArgumentException) FieldType(org.activityinfo.model.type.FieldType)

Aggregations

ArgumentException (org.activityinfo.model.formula.diagnostic.ArgumentException)1 FieldType (org.activityinfo.model.type.FieldType)1 BooleanType (org.activityinfo.model.type.primitive.BooleanType)1