View Javadoc

1   /*
2    * Created on 29-mar-2006
3    *
4    */
5   package org.state4j.sm.evaluators;
6   
7   import org.state4j.sm.SmContext;
8   import org.state4j.sm.SmEvaluator;
9   import org.state4j.sm.SmGuardCondition;
10  
11  public class SmAndOperatorEvaluatorImpl implements SmEvaluator {
12      private SmGuardCondition leftArgument;
13      private SmGuardCondition rightArgument;
14  
15      public boolean hasLeftArgument() {
16          return leftArgument != null;
17      }
18  
19      public SmGuardCondition getLeftArgument() {
20          if (!hasLeftArgument()) {
21              throw new RuntimeException("this.leftArgument is null and can't be returned");
22          }
23          return this.leftArgument;
24      }
25      public void setLeftArgument(SmGuardCondition argument) {
26          this.leftArgument = argument;
27      }
28  	public boolean evaluate(SmContext cntx) {
29  		return this.getLeftArgument().evaluate(cntx) && this.getRightArgument().evaluate(cntx);
30  	}
31  	public SmGuardCondition getRightArgument() {
32          if (!hasRightArgument()) {
33              throw new RuntimeException("this.rigthArgument is null and can't be returned");
34          }
35  		return rightArgument;
36  	}
37      public boolean hasRightArgument() {
38          return rightArgument != null;
39      }
40  	public void setRightArgument(SmGuardCondition rightArgument) {
41  		this.rightArgument = rightArgument;
42  	}
43  }