Class GlobalStockImpl
- java.lang.Object
-
- eu.kartoffelquadrat.bookstoreinternals.GlobalStockImpl
-
- All Implemented Interfaces:
GlobalStock
public class GlobalStockImpl extends Object implements GlobalStock
Implementation for the GlobalStock interface.- Author:
- Maximilian Schiedermeier
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Long,Integer>
getEntireStoreStock(String city)
Returns the entire stock of a local store.static GlobalStock
getInstance()
Singleton access method.int
getStock(String city, Long isbn)
Returns the amount in stock of a given book in a given city.Collection<String>
getStoreLocations()
Returns a list of all cities that have a local stock.void
setStock(String city, Long isbn, Integer amount)
Updates the stock for a given city.String
toString()
Helper method to convert all stored stock information into human readable format.
-
-
-
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 interfaceGlobalStock
- Parameters:
city
- for the city of interestisbn
- 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 interfaceGlobalStock
- Parameters:
city
- for the city of interestisbn
- for book id of interestamount
- 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 interfaceGlobalStock
- 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 interfaceGlobalStock
- Parameters:
city
- for the city of interest- Returns:
- a map holding for each book the amount of books in stock at the specified location.
-
-