01 /*
02 * Created on May 14, 2007
03 */
04 package com.x8ing.lsm4j.state;
05
06 import com.x8ing.lsm4j.Action;
07 import com.x8ing.lsm4j.Condition;
08
09 /**
10 *
11 * @author Patrick Heusser
12 */
13 public class ProcessableTransition extends StaticTransition {
14
15 private Condition condition = null;
16
17 /**
18 * optional action may be null.
19 */
20 private Action action = null;
21
22 /**
23 * @param currentState
24 * @param nextState
25 */
26 public ProcessableTransition(ProcessableState currentState, ProcessableState nextState,
27 Condition condition) {
28
29 super(currentState, nextState);
30 this.condition = condition;
31
32 }
33
34 public ProcessableTransition(ProcessableState currentState, ProcessableState nextState,
35 Condition condition, Action transitionAction) {
36 this(currentState, nextState, condition);
37 this.action = transitionAction;
38 }
39
40 public boolean equals(Object obj) {
41
42 if (obj == null || !(obj instanceof ProcessableTransition)) {
43 return false;
44 }
45 ProcessableTransition p2 = (ProcessableTransition) obj;
46
47 // check if conditions are equally
48 boolean eqCond = condition.equals(p2.condition);
49 boolean eqTrans = super.equals(p2);
50
51 return eqCond && eqTrans;
52 }
53
54 public int hashCode() {
55 return super.hashCode() + 192329 * condition.hashCode();
56 }
57
58 public Condition getCondition() {
59 return condition;
60 }
61
62 public void setCondition(Condition condition) {
63 this.condition = condition;
64 }
65
66 public ProcessableState getCurrentProcessableState() {
67 return (ProcessableState) currentState;
68 }
69
70 public ProcessableState getNextProcessableState() {
71 return (ProcessableState) nextState;
72 }
73
74 public Action getAction() {
75 return action;
76 }
77
78 public void setAction(Action action) {
79 this.action = action;
80 }
81 }
|