001 package sale;
002
003 import users.User;
004
005 /**
006 * Convenience implementation of a Transition that simply changes to another gate. Additionally, some other
007 * useful Transitions are provided.
008 *
009 * @see Transition
010 * @see Gate
011 *
012 * @author Steffen Zschaler
013 * @version 2.0 17/08/1999
014 * @since v2.0
015 */
016 public class GateChangeTransition extends Object implements Transition {
017
018 /**
019 * ID for serialization.
020 */
021 private static final long serialVersionUID = 3065982594077885294L;
022
023 /**
024 * The target gate.
025 *
026 * @serial
027 */
028 protected Gate m_gTarget;
029
030 /**
031 * Create a new GateChangeTransition.
032 *
033 * @param gTarget the Gate to change to.
034 */
035 public GateChangeTransition(Gate gTarget) {
036 super();
037
038 m_gTarget = gTarget;
039 }
040
041 /**
042 * Perform the Transition. I.e. go to the gate indicated on creation.
043 *
044 * @override Never
045 */
046 public final Gate perform(SaleProcess p, User u) {
047 return m_gTarget;
048 }
049
050 // some convenience constants
051 /**
052 * Transition that will go to the calling process' {@link SaleProcess#getRollbackGate rollback gate}.
053 */
054 public static final Transition CHANGE_TO_ROLLBACK_GATE = new Transition() {
055 private static final long serialVersionUID = -1803995238343349608L;
056 public Gate perform(SaleProcess p, User u) {
057 return p.getRollbackGate();
058 }
059 };
060
061 /**
062 * Transition that will go to the calling process' {@link SaleProcess#getCommitGate commit gate}.
063 */
064 public static final Transition CHANGE_TO_COMMIT_GATE = new Transition() {
065 private static final long serialVersionUID = -224101824911764518L;
066 public Gate perform(SaleProcess p, User u) {
067 return p.getCommitGate();
068 }
069 };
070
071 /**
072 * Transition that will go to the calling process' {@link SaleProcess#getQuitGate quit gate}.
073 */
074 public static final Transition CHANGE_TO_QUIT_GATE = new Transition() {
075 private static final long serialVersionUID = -8562684960459105414L;
076 public Gate perform(SaleProcess p, User u) {
077 return p.getQuitGate();
078 }
079 };
080
081 /**
082 * Transition that will go to the calling process' {@link SaleProcess#getStopGate stop gate}.
083 */
084 public static final Transition CHANGE_TO_STOP_GATE = new Transition() {
085 private static final long serialVersionUID = -444636924017240666L;
086 public Gate perform(SaleProcess p, User u) {
087 return p.getStopGate();
088 }
089 };
090
091 /**
092 * Transition that will go to the calling process' {@link SaleProcess#getLogGate log gate}.
093 */
094 public static final Transition CHANGE_TO_LOG_GATE = new Transition() {
095 private static final long serialVersionUID = 3313508636205524700L;
096 public Gate perform(SaleProcess p, User u) {
097 return p.getLogGate();
098 }
099 };
100 }