jfreerails.world.track
Class FreerailsTile

java.lang.Object
  extended by jfreerails.world.track.FreerailsTile
All Implemented Interfaces:
java.io.Serializable, FreerailsSerializable, TerrainTile

public class FreerailsTile
extends java.lang.Object
implements TerrainTile, FreerailsSerializable

A tile on the map. Instances are stored in a HashMap to avoid creating 100,000s of objects.

Author:
Luke
See Also:
Serialized Form

Field Summary
private static java.util.HashMap<FreerailsTile,FreerailsTile> instances
           
static FreerailsTile NULL
           
private static long serialVersionUID
           
private  int terrainType
           
private  TrackPiece trackPiece
           
 
Constructor Summary
private FreerailsTile(int terrainType)
           
private FreerailsTile(int terrainType, TrackPiece trackPiece)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
static FreerailsTile getInstance(int terrainType)
           
static FreerailsTile getInstance(int terrainType, TrackPiece trackPiece)
           
 int getTerrainTypeID()
           
 TrackPiece getTrackPiece()
           
 int hashCode()
           
 boolean hasTrack()
           
private  java.lang.Object readResolve()
           
 java.lang.String toString()
           
 
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

NULL

public static final FreerailsTile NULL

trackPiece

private final TrackPiece trackPiece

terrainType

private final int terrainType

instances

private static java.util.HashMap<FreerailsTile,FreerailsTile> instances
Constructor Detail

FreerailsTile

private FreerailsTile(int terrainType)

FreerailsTile

private FreerailsTile(int terrainType,
                      TrackPiece trackPiece)
Method Detail

equals

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

hashCode

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

getInstance

public static FreerailsTile getInstance(int terrainType)

getInstance

public static FreerailsTile getInstance(int terrainType,
                                        TrackPiece trackPiece)

readResolve

private java.lang.Object readResolve()
                              throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException

getTerrainTypeID

public int getTerrainTypeID()
Specified by:
getTerrainTypeID in interface TerrainTile

toString

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

getTrackPiece

public TrackPiece getTrackPiece()

hasTrack

public boolean hasTrack()