Interface ExpenseRepository

All Known Implementing Classes:
MongoExpenseRepository

public interface ExpenseRepository
Interface used for dealing with storage and retrieval of expense
  • Method Details

    • saveExpense

      @Nullable Expense saveExpense(@NonNull Expense expense)
      Saves the expense to storage
      Parameters:
      expense - Expense saved
      Returns:
      expense saved
    • getExpense

      Optional<Expense> getExpense(int id)
      Finds the expense with given id
      Parameters:
      id - ID as shown by showExpenses
      Returns:
      Expense if found else empty
    • getExpenses

      @NonNull List<Expense> getExpenses()
      Finds all the expenses saved
      Returns:
      List of all the expenses saved
    • changeExpense

      Optional<Expense> changeExpense(int id, @NonNull BigDecimal newAmount)
      Changes the expense with given ID
      Parameters:
      id - ID identifying the expense. It is the left value displayed when calling showExpenses
      newAmount - Will update the value to this value. If set to zero. The expanse will be removed
      Returns:
      Changed expense or empty if did not change