org.powertac.common
Class IdGenerator

java.lang.Object
  extended by org.powertac.common.IdGenerator

public class IdGenerator
extends Object

Generates numeric ID values for domain types. ID values are of the form xA+B, where x is the multiplier, A is a prefix, and B is the value of a counter.

Author:
John Collins

Constructor Summary
IdGenerator()
           
 
Method Summary
static long createId()
          Generates a numeric ID as xA+B.
static int getPrefix()
          Returns the id prefix - needed for testing.
static String getString(long id)
          Converts ID value to String as A.B.
static void recycle()
          Recycles the generator.
static void setPrefix(int value)
          Each entity living in a separate process must have a different prefix value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdGenerator

public IdGenerator()
Method Detail

createId

public static long createId()
Generates a numeric ID as xA+B.


setPrefix

public static void setPrefix(int value)
Each entity living in a separate process must have a different prefix value. These values are presumably set by the competition control service.


getPrefix

public static int getPrefix()
Returns the id prefix - needed for testing.


getString

public static String getString(long id)
Converts ID value to String as A.B.


recycle

public static void recycle()
Recycles the generator. This should only be used in a setting where multiple sessions are run in a single process.



Copyright © 2012. All Rights Reserved.