1 /**
2 * Copyright 2005-2012 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krms.framework.engine.expression;
17
18 import java.util.Collections;
19 import java.util.List;
20
21 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
22 import org.kuali.rice.krms.framework.engine.Proposition;
23 import org.kuali.rice.krms.framework.engine.PropositionResult;
24
25 /**
26 * An implementation of {@link Proposition} which uses a given {@link Expression}<Boolean>
27 * @author Kuali Rice Team (rice.collab@kuali.org)
28 *
29 */
30 public class ExpressionBasedProposition implements Proposition {
31
32 private final Expression<Boolean> expression;
33
34 /**
35 * Create an ExpressionBasedProposition with the given value
36 * @param expression {@link Expression} to set the expression to
37 */
38 public ExpressionBasedProposition(Expression<Boolean> expression) {
39 this.expression = expression;
40 }
41
42 @Override
43 public PropositionResult evaluate(ExecutionEnvironment environment) {
44 return new PropositionResult(expression.invoke(environment).booleanValue());
45 }
46
47
48 @Override
49 public List<Proposition> getChildren() {
50 return Collections.emptyList();
51 }
52
53 @Override
54 public boolean isCompound() {
55 return false;
56 }
57 }