unc.cdva.utils
Class TaggedObject

java.lang.Object
  extended by unc.cdva.utils.TaggedObject
All Implemented Interfaces:
Taggable
Direct Known Subclasses:
InteractiveItem, Player, ProblemTriangle

public abstract class TaggedObject
extends java.lang.Object
implements Taggable

A skeleton for a taggable object, if the object can not extend this object, then it should implement the Taggable interface.


Constructor Summary
TaggedObject()
          Constructor which creates a new Id for the newly created object
 
Method Summary
static Id createId()
          Creates a unique id.
 boolean equals(java.lang.Object o)
          Checks if object o is equal to this object
 Id getId()
           
 int hashCode()
          Turns the Id into a new value to be used for further identification of this object
 void setId(Id newId)
          Sets the Id to be equal to the Id sent
 void setId(long newId)
          Sets the Id to the new long value sent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaggedObject

public TaggedObject()
Constructor which creates a new Id for the newly created object

Method Detail

hashCode

public int hashCode()
Turns the Id into a new value to be used for further identification of this object

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Checks if object o is equal to this object

Overrides:
equals in class java.lang.Object

getId

public Id getId()
Specified by:
getId in interface Taggable
Returns:
Id

setId

public void setId(long newId)
Sets the Id to the new long value sent

Parameters:
newId -

setId

public void setId(Id newId)
Sets the Id to be equal to the Id sent

Parameters:
newId -

createId

public static Id createId()
Creates a unique id. So far the method can be called fairly rapidly and will still generate unique id's. It may not be thread safe, and there may be conditions where with multiple threads, that this method could return a non-unique id.

Returns:
A long representing a unique identifier.