1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.framework.engine.expression;
17
18 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
19 import org.kuali.rice.krms.api.engine.IncompatibleTypeException;
20
21
22
23
24
25
26
27 public final class BooleanValidatingExpression implements Expression<Boolean> {
28
29 private final Expression<? extends Object> expression;
30
31 public BooleanValidatingExpression(Expression<? extends Object> expression) {
32 this.expression = expression;
33 }
34
35 public Boolean invoke(ExecutionEnvironment environment) {
36 Object result = expression.invoke(environment);
37 if (result instanceof Boolean) {
38 return (Boolean)result;
39 }
40 throw new IncompatibleTypeException("Type mismatch when executing expression.", result, Boolean.class);
41 }
42
43 }