Package org.powertac.common
Class IdGenerator
- java.lang.Object
- 
- 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 an integer prefix, and B is the value of a counter incremented with each call. The use of a prefix allows the server to give each broker a space of ID values and prevent collisions.- Author:
- John Collins
 
- 
- 
Constructor SummaryConstructors Constructor Description IdGenerator()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static longcreateId()Generates a numeric ID as xA+B.static intextractPrefix(long id)Returns the id prefix for the given id.static intgetMultiplier()Returns the multiplier for an id, needed to validate id valuesstatic intgetPrefix()Returns the id prefix - needed for testing.static StringgetString(long id)Converts ID value to String as A.B.static voidrecycle()Recycles the generator.static voidsetPrefix(int value)Each entity living in a separate process must have a different prefix value.
 
- 
- 
- 
Method Detail- 
createIdpublic static long createId() Generates a numeric ID as xA+B.
 - 
setPrefixpublic 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.
 - 
getPrefixpublic static int getPrefix() Returns the id prefix - needed for testing.
 - 
getStringpublic static String getString(long id) Converts ID value to String as A.B.
 - 
getMultiplierpublic static int getMultiplier() Returns the multiplier for an id, needed to validate id values
 - 
extractPrefixpublic static int extractPrefix(long id) Returns the id prefix for the given id.
 - 
recyclepublic static void recycle() Recycles the generator. This should only be used in a setting where multiple sessions are run in a single process.
 
- 
 
-