Class ContractBrokers

  • All Implemented Interfaces:
    IContractBrokers

    @Component
    public class ContractBrokers
    extends java.lang.Object
    implements IContractBrokers
    List of all contract brokers
    Author:
    Andi Hotz, (c) Sahits GmbH, 2018 Created on Apr 30, 2018
    • Field Detail

      • clientServerEventBus

        @Autowired
        @Qualifier("serverClientEventBus")
        private com.google.common.eventbus.AsyncEventBus clientServerEventBus
    • Constructor Detail

      • ContractBrokers

        public ContractBrokers()
    • Method Detail

      • init

        @PostConstruct
        private void init()
      • assignPlayer

        public void assignPlayer​(IPlayer player,
                                 IContractBroker broker,
                                 java.time.LocalDateTime deadline)
        Assign a player to a contract broker.
        Parameters:
        player - to be assigned
        broker - to whom the player is assigned.
        deadline - until when the wares have to be delivered.
      • remove

        public void remove​(IContractBroker broker)
        Remove the connections matching a specific broker.
        Parameters:
        broker - to be removed.
      • removePastDeadline

        public void removePastDeadline​(PeriodicalDailyUpdate event)
        Daily checking if the deadline has passed.
        Parameters:
        event -
      • findContractBroker

        public java.util.Optional<IContractBroker> findContractBroker​(ICity city,
                                                                      IPlayer player)
        Description copied from interface: IContractBrokers
        Retrieve the contract broker in the city, who is waiting for a delivery by the player.
        Specified by:
        findContractBroker in interface IContractBrokers
        Parameters:
        city - for which to look up the contract broker.
        player - from whom the broker awaits d deliver.
        Returns:
        optional of the broker, if one is found, empty otherwise.
      • hasContractBroker

        public boolean hasContractBroker​(ICity city)
        Description copied from interface: IContractBrokers
        Check if there is a contract broker defined for the city. It does not matter, if the broker has an assigned player or not.
        Specified by:
        hasContractBroker in interface IContractBrokers
        Parameters:
        city - for which to check the contract broker
        Returns:
        true if there is a contract broker defined for the city.