public class JSONInstanceHandler extends InstanceHandler
| Modifier and Type | Method and Description |
|---|---|
static JSONInstanceHandler |
getInstance() |
long |
getNextPopulationId(long worldId)
Returns a new population id
The id is unique amongst all previously generated population ids with the same worldId.
|
long |
getNextWorldId()
Returns an new unused world id.
|
Collection<Long> |
getPopulationIds(long worldId) |
<T extends Bidder<?>> |
readBidder(Class<T> type,
World world,
long populationId,
long bidderId)
Used to deserialize a bidder, if its implementing class is known
|
<T extends Bidder<?>> |
readBidderWithUnknownType(Class<T> bidderSuperType,
World world,
long populationId,
long bidderId)
Used to deserialize a bidder, if its type is not exactly known,
i.e., if there are different bidder implementations for this model.
|
<T extends Bidder<?>> |
readPopulation(Class<T> type,
World world,
long populationId)
Used to deserialize a set of bidders, if the implementing class of all bidders is known and the same
|
<T extends Bidder<?>> |
readPopulationWithUnknownTypes(Class<T> bidderSuperType,
World world,
long populationId)
Used to deserialize a set of bidders, if their type is not exactly known,
i.e., if there are different bidder implementations for this model.
|
<T extends World> |
readWorld(Class<T> type,
long worldId)
Reads a world instance.
|
void |
writeBidder(Bidder<?> bidder)
Writes a new bidder instance.
|
void |
writeWorld(World world)
Writes a world instance.
|
getDefaultHandler, setDefaultHandlerpublic static JSONInstanceHandler getInstance()
public void writeWorld(World world)
InstanceHandlerwriteWorld in class InstanceHandlerworld - the world to be writtenpublic void writeBidder(Bidder<?> bidder)
InstanceHandlerwriteBidder in class InstanceHandlerbidder - the bidder to be writtenpublic Collection<Long> getPopulationIds(long worldId)
getPopulationIds in class InstanceHandlerpublic <T extends Bidder<?>> T readBidderWithUnknownType(Class<T> bidderSuperType, World world, long populationId, long bidderId)
InstanceHandlerreadBidderWithUnknownType in class InstanceHandlerbidderSuperType - the deserialized bidder is either of class bidderSuperType or of a subclass of bidderSuperTypeworld - the world the bidder lives inpopulationId - the id of the populationbidderId - the id of the bidderpublic <T extends Bidder<?>> T readBidder(Class<T> type, World world, long populationId, long bidderId)
InstanceHandlerreadBidder in class InstanceHandlertype - the class of which a new instance should be createdworld - the world the bidder lives inpopulationId - the id of the populationbidderId - the id of the bidderpublic <T extends Bidder<?>> Collection<T> readPopulationWithUnknownTypes(Class<T> bidderSuperType, World world, long populationId)
InstanceHandlerreadPopulationWithUnknownTypes in class InstanceHandlerbidderSuperType - the deserialized bidder is either of class bidderSuperType or of a subclass of bidderSuperTypeworld - the world the bidders live inpopulationId - the id of the populationpublic <T extends Bidder<?>> Collection<T> readPopulation(Class<T> type, World world, long populationId)
InstanceHandlerreadPopulation in class InstanceHandlertype - the class of which the new bidder instances should be createdworld - the world the bidders live inpopulationId - the id of the populationpublic long getNextWorldId()
InstanceHandlergetNextWorldId in class InstanceHandlerpublic long getNextPopulationId(long worldId)
InstanceHandlergetNextPopulationId in class InstanceHandlerworldId - The id of the world to which the new population will belongpublic <T extends World> T readWorld(Class<T> type, long worldId)
InstanceHandlerreadWorld in class InstanceHandlerCopyright © 2017. All rights reserved.