jfreerails.world.cargo
Class MutableCargoBundle

java.lang.Object
  extended by jfreerails.world.cargo.MutableCargoBundle
All Implemented Interfaces:
CargoBundle

public class MutableCargoBundle
extends java.lang.Object
implements CargoBundle

This CargoBundle implementation uses a java.util.SortedMap to map quantities to cargo batches.

Author:
Luke

Field Summary
private  java.util.SortedMap<CargoBatch,java.lang.Integer> sortedMap
           
private  int updateID
           
 
Constructor Summary
MutableCargoBundle()
           
MutableCargoBundle(ImmutableCargoBundle imcb)
           
 
Method Summary
 void addCargo(CargoBatch cb, int amount)
           
 java.util.Iterator<CargoBatch> cargoBatchIterator()
          Note, calling hasNext() or next() on the returned iterator throws a ConcurrentModificationException if this CargoBundle has changed since the iterator was aquired.
 boolean contains(CargoBatch cb)
           
 boolean equals(java.lang.Object arg0)
           
 int getAmount(CargoBatch cb)
           
 int getAmount(int cargoType)
           
 int hashCode()
           
 void setAmount(CargoBatch cb, int amount)
           
 int size()
           
 ImmutableCargoBundle toImmutableCargoBundle()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

sortedMap

private final java.util.SortedMap<CargoBatch,java.lang.Integer> sortedMap

updateID

private int updateID
Constructor Detail

MutableCargoBundle

public MutableCargoBundle()

MutableCargoBundle

public MutableCargoBundle(ImmutableCargoBundle imcb)
Method Detail

addCargo

public void addCargo(CargoBatch cb,
                     int amount)

cargoBatchIterator

public java.util.Iterator<CargoBatch> cargoBatchIterator()
Note, calling hasNext() or next() on the returned iterator throws a ConcurrentModificationException if this CargoBundle has changed since the iterator was aquired.

Specified by:
cargoBatchIterator in interface CargoBundle

contains

public boolean contains(CargoBatch cb)
Specified by:
contains in interface CargoBundle

equals

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

getAmount

public int getAmount(CargoBatch cb)
Specified by:
getAmount in interface CargoBundle

getAmount

public int getAmount(int cargoType)
Specified by:
getAmount in interface CargoBundle

hashCode

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

setAmount

public void setAmount(CargoBatch cb,
                      int amount)

size

public int size()
Specified by:
size in interface CargoBundle

toImmutableCargoBundle

public ImmutableCargoBundle toImmutableCargoBundle()

toString

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