Class GlobalStockImpl

  • All Implemented Interfaces:
    GlobalStock

    public class GlobalStockImpl
    extends Object
    implements GlobalStock
    Implementation for the GlobalStock interface.
    Author:
    Maximilian Schiedermeier
    • Method Detail

      • getInstance

        public static GlobalStock getInstance()
        Singleton access method.
        Returns:
        the singleton instance.
      • getStock

        public int getStock​(String city,
                            Long isbn)
        Returns the amount in stock of a given book in a given city.
        Specified by:
        getStock in interface GlobalStock
        Parameters:
        city - for the city of interest
        isbn - for book id of interest
        Returns:
        the amount in stock
      • setStock

        public void setStock​(String city,
                             Long isbn,
                             Integer amount)
        Updates the stock for a given city.
        Specified by:
        setStock in interface GlobalStock
        Parameters:
        city - for the city of interest
        isbn - for book id of interest
        amount - for the new amount in stock
      • getStoreLocations

        public Collection<String> getStoreLocations()
        Returns a list of all cities that have a local stock.
        Specified by:
        getStoreLocations in interface GlobalStock
        Returns:
        a list of all cities (strings)
      • getEntireStoreStock

        public Map<Long,​Integer> getEntireStoreStock​(String city)
        Returns the entire stock of a local store.
        Specified by:
        getEntireStoreStock in interface GlobalStock
        Parameters:
        city - for the city of interest
        Returns:
        a map holding for each book the amount of books in stock at the specified location.
      • toString

        public String toString()
        Helper method to convert all stored stock information into human readable format.
        Overrides:
        toString in class Object
        Returns:
        A nicely formatted string listing all local stocks.