cz.cuni.amis.pogamut.base.communication.worldview.object
Class WorldObjectId

Package class diagram package WorldObjectId
java.lang.Object
  extended by cz.cuni.amis.pogamut.base.communication.worldview.object.WorldObjectId
All Implemented Interfaces:
Serializable

public class WorldObjectId
extends Object
implements Serializable

Interface that is returning an unique id of the world object. The id must be unique among all the objects in the world.

Every implementations MUST implement equals() and hashCode() correctly as we will use this inside hashmaps/sets.

Author:
Jimmy
See Also:
Serialized Form

Field Summary
protected  boolean isDouble
          Whether the id wolds 'double' inside token.
protected  boolean isLong
          Whether the id wolds 'long' inside token.
protected  cz.cuni.amis.utils.token.Token token
          Unique representation of this id, contains ints that uniquely identifies it.
 
Constructor Summary
protected WorldObjectId(double id)
          Instantiates a new object with id of 'id'.
protected WorldObjectId(long id)
          Instantiates a new object with id of 'id'.
protected WorldObjectId(String name)
          Instantiates a new object with id of 'name'.
protected WorldObjectId(cz.cuni.amis.utils.token.Token token)
           
 
Method Summary
 boolean equals(Object o)
           
static WorldObjectId get(double objId)
          Returns shared instance of the WorldObjectId for 'objId'.
static WorldObjectId get(long objId)
          Returns shared instance of the WorldObjectId for 'objId'.
static WorldObjectId get(String name)
          Returns shared instance of the WorldObjectId for 'name'.
 double getDoubleId()
          Returns id as 'double', only iff isDoubleId(), otherwise it raises a PogamutException.
 long getLongId()
          Returns id as 'long', only iff isLongId(), otherwise it raises a PogamutException.
 String getStringId()
          Always returns a string representation of the ID.
 int hashCode()
           
 boolean isDoubleId()
          Whether the is is a double one.
 boolean isLongId()
          Whether the id is a long one.
 boolean isNumericId()
          Whether the id holds a numeric value (i.e., it is either isLongId() or isDoubleId()).
 String toString()
          Returns string representation of the id, format: WorldObjectId[id]
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

token

protected cz.cuni.amis.utils.token.Token token
Unique representation of this id, contains ints that uniquely identifies it.


isLong

protected boolean isLong
Whether the id wolds 'long' inside token.


isDouble

protected boolean isDouble
Whether the id wolds 'double' inside token.

Constructor Detail

WorldObjectId

protected WorldObjectId(String name)
Instantiates a new object with id of 'name'.

Parameters:
name -

WorldObjectId

protected WorldObjectId(long id)
Instantiates a new object with id of 'id'.

Parameters:
id -

WorldObjectId

protected WorldObjectId(double id)
Instantiates a new object with id of 'id'.

Parameters:
id -

WorldObjectId

protected WorldObjectId(cz.cuni.amis.utils.token.Token token)
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

getStringId

public String getStringId()
Always returns a string representation of the ID.

Returns:

isNumericId

public boolean isNumericId()
Whether the id holds a numeric value (i.e., it is either isLongId() or isDoubleId()).

Returns:

isLongId

public boolean isLongId()
Whether the id is a long one.

Returns:

isDoubleId

public boolean isDoubleId()
Whether the is is a double one.

Returns:

getLongId

public long getLongId()
Returns id as 'long', only iff isLongId(), otherwise it raises a PogamutException.

Returns:
long

getDoubleId

public double getDoubleId()
Returns id as 'double', only iff isDoubleId(), otherwise it raises a PogamutException.

Returns:
long

toString

public String toString()
Returns string representation of the id, format: WorldObjectId[id]

Overrides:
toString in class Object
Returns:
string representation of this object

get

public static WorldObjectId get(String name)
Returns shared instance of the WorldObjectId for 'name'. If no WorldObjectId exists for 'name', new one is created.

THREAD-SAFE!

Parameters:
name -
Returns:

get

public static WorldObjectId get(long objId)
Returns shared instance of the WorldObjectId for 'objId'. If no WorldObjectId exists for 'objId', new one is created.

THREAD-SAFE!

Parameters:
name -
Returns:

get

public static WorldObjectId get(double objId)
Returns shared instance of the WorldObjectId for 'objId'. If no WorldObjectId exists for 'objId', new one is created.

THREAD-SAFE!

Parameters:
name -
Returns:


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.