Class MongoStockRepository

java.lang.Object
com.truebubo.maniflow.stock.MongoStockRepository
All Implemented Interfaces:
StockRepository

@Repository public class MongoStockRepository extends Object implements StockRepository
Repository used for dealing with storage and retrieval of stock using MongoDB
  • Constructor Details

    • MongoStockRepository

      public MongoStockRepository(@NonNull com.mongodb.client.MongoClient mongoClient)
      Creates mongo repository
      Parameters:
      mongoClient - Mongo client to be used
  • Method Details

    • saveStock

      @NonNull public Stock saveStock(@NonNull Stock stock)
      Description copied from interface: StockRepository
      Saves the stock to storage
      Specified by:
      saveStock in interface StockRepository
      Parameters:
      stock - Stock saved
      Returns:
      stock saved
    • deleteStock

      public void deleteStock(String ticket)
      Description copied from interface: StockRepository
      Removes the stock with given ticket
      Specified by:
      deleteStock in interface StockRepository
      Parameters:
      ticket - Ticket associated with the stock
    • getStock

      public Optional<Stock> getStock(String ticket)
      Description copied from interface: StockRepository
      Finds the stock in storage
      Specified by:
      getStock in interface StockRepository
      Parameters:
      ticket - Ticket associated with the stock
      Returns:
      Stock if found or empty if not
    • getStocks

      public List<Stock> getStocks()
      Description copied from interface: StockRepository
      Finds all the stocks saved
      Specified by:
      getStocks in interface StockRepository
      Returns:
      List of all the stocks saved