jfreerails.move
Class ChangeItemInListMove

java.lang.Object
  extended by jfreerails.move.ChangeItemInListMove
All Implemented Interfaces:
java.io.Serializable, ListMove, Move, FreerailsSerializable
Direct Known Subclasses:
ChangeCargoBundleMove, ChangeStationMove, ChangeTrainMove, ChangeTrainScheduleMove

public class ChangeItemInListMove
extends java.lang.Object
implements ListMove

All Moves that replace an item in a list with another should extend this class.

Author:
Luke
See Also:
Serialized Form

Field Summary
private  FreerailsSerializable after
           
private  FreerailsSerializable before
           
private  int index
           
private  KEY listKey
           
private  FreerailsPrincipal principal
           
private static long serialVersionUID
           
 
Constructor Summary
ChangeItemInListMove(KEY k, int index, FreerailsSerializable before, FreerailsSerializable after, FreerailsPrincipal p)
           
 
Method Summary
 boolean beforeEqualsAfter()
           
 MoveStatus doMove(World w, FreerailsPrincipal p)
          Executes this move on the specifed world object.
 boolean equals(java.lang.Object o)
           
 FreerailsSerializable getAfter()
           
 FreerailsSerializable getBefore()
           
 int getIndex()
           
 KEY getKey()
           
 FreerailsPrincipal getPrincipal()
           
 int hashCode()
           
protected  MoveStatus move(FreerailsSerializable to, FreerailsSerializable from, World w)
           
 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.
protected  MoveStatus tryMove(FreerailsSerializable to, FreerailsSerializable from, World w)
           
 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.
 
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

listKey

private final KEY listKey

index

private final int index

before

private final FreerailsSerializable before

after

private final FreerailsSerializable after

principal

private final FreerailsPrincipal principal
Constructor Detail

ChangeItemInListMove

public ChangeItemInListMove(KEY k,
                            int index,
                            FreerailsSerializable before,
                            FreerailsSerializable after,
                            FreerailsPrincipal p)
Method Detail

beforeEqualsAfter

public boolean beforeEqualsAfter()

doMove

public 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

equals

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

getAfter

public FreerailsSerializable getAfter()
Specified by:
getAfter in interface ListMove
Returns:
the new item or null if not any.

getBefore

public FreerailsSerializable getBefore()
Specified by:
getBefore in interface ListMove
Returns:
the old item or null if not any.

getIndex

public int getIndex()
Specified by:
getIndex in interface ListMove
Returns:
the index of the item which changed.

getKey

public KEY getKey()
Specified by:
getKey in interface ListMove
Returns:
the type of object which was changed

getPrincipal

public FreerailsPrincipal getPrincipal()
Specified by:
getPrincipal in interface ListMove

hashCode

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

move

protected MoveStatus move(FreerailsSerializable to,
                          FreerailsSerializable from,
                          World w)

toString

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

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

tryMove

protected MoveStatus tryMove(FreerailsSerializable to,
                             FreerailsSerializable from,
                             World w)

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

undoMove

public 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