Class InstanceHandler

    • Constructor Summary

      Constructors 
      Constructor Description
      InstanceHandler()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static InstanceHandler getDefaultHandler()
      Get the default instance handler.
      abstract long getNextPopulationId​(long worldId)
      Returns a new population id The id is unique amongst all previously generated population ids with the same worldId.
      abstract long getNextWorldId()
      Returns an new unused world id.
      abstract java.util.Collection<java.lang.Long> getPopulationIds​(long worldId)  
      abstract <T extends SATSBidder>
      T
      readBidder​(java.lang.Class<T> type, World world, long populationId, long bidderId)
      Used to deserialize a bidder, if its implementing class is known
      abstract <T extends SATSBidder>
      T
      readBidderWithUnknownType​(java.lang.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.
      abstract <T extends SATSBidder>
      java.util.Collection<T>
      readPopulation​(java.lang.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
      abstract <T extends SATSBidder>
      java.util.List<T>
      readPopulationWithUnknownTypes​(java.lang.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.
      abstract <T extends World>
      T
      readWorld​(java.lang.Class<T> type, long world)
      Reads a world instance.
      static void setDefaultHandler​(InstanceHandler defaultHandler)
      Set a new default instance handler.
      The default instance handler is called on every World, population and SATSBidder creation for id selection and default storing.
      abstract void writeBidder​(SATSBidder bidder)
      Writes a new bidder instance.
      abstract void writeWorld​(World world)
      Writes a world instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InstanceHandler

        public InstanceHandler()
    • Method Detail

      • getDefaultHandler

        public static InstanceHandler getDefaultHandler()
        Get the default instance handler.
        The default instance handler is called on every World, population and SATSBidder creation for id selection and default storing.
        Returns:
        the default instance handler
      • setDefaultHandler

        public static void setDefaultHandler​(InstanceHandler defaultHandler)
        Set a new default instance handler.
        The default instance handler is called on every World, population and SATSBidder creation for id selection and default storing.
        Parameters:
        defaultHandler - the new default instance handler
      • writeWorld

        public abstract void writeWorld​(World world)
        Writes a world instance. If a world with the same id already is stored, it might be overwritten.
        Parameters:
        world - the world to be written
      • readWorld

        public abstract <T extends World> T readWorld​(java.lang.Class<T> type,
                                                      long world)
        Reads a world instance.
      • writeBidder

        public abstract void writeBidder​(SATSBidder bidder)
        Writes a new bidder instance. If a bidder with the same world and population id already is stored, it might be overwritten.
        Parameters:
        bidder - the bidder to be written
      • getPopulationIds

        public abstract java.util.Collection<java.lang.Long> getPopulationIds​(long worldId)
        Returns:
        A collection containing all ids of the stored population for the requested world
      • readBidder

        public abstract <T extends SATSBidder> T readBidder​(java.lang.Class<T> type,
                                                            World world,
                                                            long populationId,
                                                            long bidderId)
        Used to deserialize a bidder, if its implementing class is known
        Parameters:
        type - the class of which a new instance should be created
        world - the world the bidder lives in
        populationId - the id of the population
        bidderId - the id of the bidder
        Returns:
        the deserialized bidder
      • readBidderWithUnknownType

        public abstract <T extends SATSBidder> T readBidderWithUnknownType​(java.lang.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.
        Parameters:
        bidderSuperType - the deserialized bidder is either of class bidderSuperType or of a subclass of bidderSuperType
        world - the world the bidder lives in
        populationId - the id of the population
        bidderId - the id of the bidder
        Returns:
        the deserialized bidder
      • readPopulation

        public abstract <T extends SATSBidder> java.util.Collection<T> readPopulation​(java.lang.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
        Parameters:
        type - the class of which the new bidder instances should be created
        world - the world the bidders live in
        populationId - the id of the population
        Returns:
        the deserialized bidders
      • readPopulationWithUnknownTypes

        public abstract <T extends SATSBidder> java.util.List<T> readPopulationWithUnknownTypes​(java.lang.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.
        Parameters:
        bidderSuperType - the deserialized bidder is either of class bidderSuperType or of a subclass of bidderSuperType
        world - the world the bidders live in
        populationId - the id of the population
        Returns:
        the deserialized bidders
      • getNextWorldId

        public abstract long getNextWorldId()
        Returns an new unused world id. The id is unique amongst all previously generated world ids.
        Returns:
        an unused world id
      • getNextPopulationId

        public abstract long getNextPopulationId​(long worldId)
        Returns a new population id The id is unique amongst all previously generated population ids with the same worldId.
        Parameters:
        worldId - The id of the world to which the new population will belong
        Returns:
        a new population id