Class MongoIncomeRepository

java.lang.Object
com.truebubo.maniflow.income.MongoIncomeRepository
All Implemented Interfaces:
IncomeRepository

@Repository public class MongoIncomeRepository extends Object implements IncomeRepository
Repository used for dealing with storage and retrieval of income using MongoDB
  • Constructor Details

    • MongoIncomeRepository

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

    • saveIncome

      @Nullable public Income saveIncome(@NonNull Income income)
      Description copied from interface: IncomeRepository
      Saves the income to storage
      Specified by:
      saveIncome in interface IncomeRepository
      Parameters:
      income - Income saved
      Returns:
      income saved
    • getIncome

      @NonNull public Optional<Income> getIncome(int id)
      Description copied from interface: IncomeRepository
      Finds the income with given id
      Specified by:
      getIncome in interface IncomeRepository
      Parameters:
      id - as shown in list
      Returns:
      Income if found else empty
    • getIncomes

      @NonNull public List<Income> getIncomes()
      Description copied from interface: IncomeRepository
      Finds all the incomes saved
      Specified by:
      getIncomes in interface IncomeRepository
      Returns:
      List of all the incomes saved
    • changeIncome

      @Nullable public Optional<Income> changeIncome(int id, @NonNull BigDecimal newAmount)
      Description copied from interface: IncomeRepository
      Changes the income with given ID
      Specified by:
      changeIncome in interface IncomeRepository
      Parameters:
      id - ID identifying the income. It is the left value displayed when calling showIncomes
      newAmount - Will update the value to this value. If set to zero. The value will be removed
      Returns:
      new income if changed, else empty