Class MongoDebtRepository

java.lang.Object
com.truebubo.maniflow.debt.MongoDebtRepository
All Implemented Interfaces:
DebtRepository

@Repository public class MongoDebtRepository extends Object implements DebtRepository
Repository used for dealing with storage and retrieval of debts using MongoDB
  • Constructor Details

    • MongoDebtRepository

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

    • saveDebt

      public Debt saveDebt(@NonNull Debt debt)
      Description copied from interface: DebtRepository
      Saves the debt to storage
      Specified by:
      saveDebt in interface DebtRepository
      Parameters:
      debt - Debt saved
      Returns:
      debt saved
    • getDebt

      public Optional<Debt> getDebt(int id)
      Description copied from interface: DebtRepository
      Finds the debt with given id
      Specified by:
      getDebt in interface DebtRepository
      Parameters:
      id - ID as shown in showDebts
      Returns:
      Debt if found otherwise empty
    • getDebts

      public List<Debt> getDebts()
      Description copied from interface: DebtRepository
      Finds all the current debt
      Specified by:
      getDebts in interface DebtRepository
      Returns:
      List of all the debts saved
    • changeDebt

      public Optional<Debt> changeDebt(int id, @NonNull BigDecimal newAmount)
      Description copied from interface: DebtRepository
      Changes the debt with given id
      Specified by:
      changeDebt in interface DebtRepository
      Parameters:
      id - ID identifying the debt. It is the left value displayed when calling showExpenses
      newAmount - Will update the value to this value. If set to zero. The debt will be erased
      Returns:
      Value of new debt or empty if not exist