org.moyoman.util
Class GameId

java.lang.Object
  |
  +--org.moyoman.util.GameId
All Implemented Interfaces:
Serializable

public class GameId
extends Object
implements Serializable

This class encapsulates a String that represents a game. It ensures that ids are unique in that they don't conflict with active games or games in permanent storage.

See Also:
Serialized Form

Field Summary
private static HashSet active
          This is a Set containing the active GameId objects.
private  String id
          The id of the game.
private static HashMap komi
          The key is the GameId object, and the value a Float object.
 
Constructor Summary
GameId()
          Create a new GameId object.
GameId(String str, boolean unique)
          Generate a GameId object with the value of the parameter str.
 
Method Summary
 boolean equals(Object o)
           
private  boolean exists(GameId gid)
           
private  boolean gameIdExists(GameId id)
           
 String get()
          Return the game id.
 float getKomi()
           
private  String getNext()
           
private  String getUnsynchronized()
           
 int hashCode()
           
 void setKomi(float k)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

private String id
The id of the game.


active

private static HashSet active
This is a Set containing the active GameId objects.


komi

private static HashMap komi
The key is the GameId object, and the value a Float object.

Constructor Detail

GameId

public GameId()
Create a new GameId object. Make sure that the id generated is unique.


GameId

public GameId(String str,
              boolean unique)
       throws IllegalArgumentException
Generate a GameId object with the value of the parameter str. Check to make sure that this value is not already in use by an active game or game in permanent storage if unique is set to true.

Parameters:
str - The value of the game id.
unique - If true, then throw an exception if the id is already in use.
Throws:
IllegalArgumentException - Thrown if unique is true and the id already exists.
Method Detail

gameIdExists

private boolean gameIdExists(GameId id)

getNext

private String getNext()

getUnsynchronized

private String getUnsynchronized()

exists

private boolean exists(GameId gid)

get

public String get()
Return the game id.

Returns:
The game id.

setKomi

public void setKomi(float k)

getKomi

public float getKomi()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object