01 /*
02 * Created on May 14, 2007
03 */
04 package com.x8ing.lsm4j.state;
05
06 /**
07 * Defines a transition between two states.
08 *
09 * @author Patrick Heusser
10 */
11 public class StaticTransition {
12
13 protected StaticState currentState = null;
14
15 protected StaticState nextState = null;
16
17 public StaticTransition(StaticState currentState, StaticState nextState) {
18
19 if (currentState == null || nextState == null) {
20 String msg = "IllegalStateTransition. StaticState must not be null. currentState=" + currentState + " nextState="
21 + nextState;
22 throw new IllegalArgumentException(msg);
23 }
24
25 this.currentState = currentState;
26 this.nextState = nextState;
27
28 }
29
30 public boolean equals(Object obj) {
31
32 if (obj == null || !(obj instanceof StaticTransition)) {
33 return false;
34 }
35
36 StaticTransition t2 = (StaticTransition) obj;
37
38 return this.currentState.equals(t2.currentState) && this.nextState.equals(t2.nextState);
39 }
40
41 public int hashCode() {
42 return currentState.hashCode() * 1337 + nextState.hashCode();
43 }
44
45 public String toString() {
46 return "StaticTransition {currentState=" + currentState + " nextState=" + nextState + " } ";
47 }
48
49 public StaticState getCurrentState() {
50 return currentState;
51 }
52
53 public StaticState getNextState() {
54 return nextState;
55 }
56
57 }
|