1 /** 2 * Copyright 2005-2013 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 org.kuali.rice.krms.api.engine.ExecutionEnvironment; 19 20 /** 21 * Binary Operator implementation of Expression<Boolean> 22 * 23 * @author Kuali Rice Team (rice.collab@kuali.org) 24 * 25 */ 26 public final class BinaryOperatorExpression implements Expression<Boolean> { 27 28 private final ComparisonOperator operator; 29 private final Expression<? extends Object> lhs; 30 private final Expression<? extends Object> rhs; 31 32 /** 33 * Create a BinaryOperatorExpression with the given values 34 * @param operator {@link ComparisonOperator} 35 * @param lhs left hand side Expression 36 * @param rhs right hand side Expression 37 */ 38 public BinaryOperatorExpression(ComparisonOperator operator, Expression<? extends Object> lhs, Expression<? extends Object> rhs) { 39 this.operator = operator; 40 this.lhs = lhs; 41 this.rhs = rhs; 42 } 43 44 @Override 45 public Boolean invoke(ExecutionEnvironment environment) { 46 Object lhsValue = lhs.invoke(environment); 47 Object rhsValue = rhs.invoke(environment); 48 return operator.compare(lhsValue, rhsValue); 49 } 50 51 }