jfreerails.move
Class CompositeMove

java.lang.Object
  extended by jfreerails.move.CompositeMove
All Implemented Interfaces:
java.io.Serializable, Move, FreerailsSerializable
Direct Known Subclasses:
AddStationMove, ChangeTrackPieceCompositeMove, RemoveStationMove, RemoveTrainMove, TransferCargoAtStationMove, UpgradeTrackMove

public class CompositeMove
extends java.lang.Object
implements Move

This Move may be subclassed to create a move composed of a number of component Moves where atomicity of the move is required. This class defines a number of methods which may not be subclassed - all changes must be encapsulated as sub-moves of this move.

Author:
Luke
See Also:
Serialized Form

Field Summary
private  ImList<Move> moves
           
private static long serialVersionUID
           
 
Constructor Summary
CompositeMove(java.util.List<Move> movesArrayList)
           
CompositeMove(Move... moves)
           
 
Method Summary
(package private)  MoveStatus compositeTest(World w, FreerailsPrincipal p)
          Subclasses may override this method to perform tests which pass or fail depending on the combination of moves making up this composite move.
 MoveStatus doMove(World w, FreerailsPrincipal p)
          Executes this move on the specifed world object.
 boolean equals(java.lang.Object o)
           
(package private)  Move getMove(int i)
          This method lets sub classes look at the moves.
 ImList<Move> getMoves()
           
 int hashCode()
           
private  void redoMoves(World w, int number, FreerailsPrincipal p)
           
 int size()
           
 java.lang.String toString()
           
 MoveStatus tryDoMove(World w, FreerailsPrincipal p)
          Tests whether this Move can be executed on the specifed world object, this method should leave the world object unchanged.
 MoveStatus tryUndoMove(World w, FreerailsPrincipal p)
          Tests whether this Move can be undone on the specifed world object, this method should leave the world object unchanged.
 MoveStatus undoMove(World w, FreerailsPrincipal p)
          If doMove has just been executed on the specified world object, calling this method changes the state of the world object back to how it was before doMove was called.
private  void undoMoves(World w, int number, FreerailsPrincipal p)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

moves

private final ImList<Move> moves
Constructor Detail

CompositeMove

public CompositeMove(java.util.List<Move> movesArrayList)

CompositeMove

public CompositeMove(Move... moves)
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getMove

final Move getMove(int i)
This method lets sub classes look at the moves.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getMoves

public final ImList<Move> getMoves()

tryDoMove

public MoveStatus tryDoMove(World w,
                            FreerailsPrincipal p)
Description copied from interface: Move
Tests whether this Move can be executed on the specifed world object, this method should leave the world object unchanged.

Specified by:
tryDoMove in interface Move

tryUndoMove

public MoveStatus tryUndoMove(World w,
                              FreerailsPrincipal p)
Description copied from interface: Move
Tests whether this Move can be undone on the specifed world object, this method should leave the world object unchanged.

Specified by:
tryUndoMove in interface Move

doMove

public final MoveStatus doMove(World w,
                               FreerailsPrincipal p)
Description copied from interface: Move
Executes this move on the specifed world object.

Specified by:
doMove in interface Move

undoMove

public final MoveStatus undoMove(World w,
                                 FreerailsPrincipal p)
Description copied from interface: Move
If doMove has just been executed on the specified world object, calling this method changes the state of the world object back to how it was before doMove was called.

Specified by:
undoMove in interface Move

undoMoves

private void undoMoves(World w,
                       int number,
                       FreerailsPrincipal p)

redoMoves

private void redoMoves(World w,
                       int number,
                       FreerailsPrincipal p)

compositeTest

MoveStatus compositeTest(World w,
                         FreerailsPrincipal p)
Subclasses may override this method to perform tests which pass or fail depending on the combination of moves making up this composite move.


size

public int size()

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object