Class MongoExpenseRepository
java.lang.Object
com.truebubo.maniflow.expense.MongoExpenseRepository
- All Implemented Interfaces:
ExpenseRepository
Repository used for dealing with storage and retrieval of expense using MongoDB
-
Constructor Summary
ConstructorsConstructorDescriptionMongoExpenseRepository
(com.mongodb.client.MongoClient mongoClient) Creates mongo repository -
Method Summary
Modifier and TypeMethodDescriptionchangeExpense
(int id, BigDecimal newAmount) Changes the expense with given IDgetExpense
(int id) Finds the expense with given idFinds all the expenses savedsaveExpense
(Expense expense) Saves the expense to storage
-
Constructor Details
-
MongoExpenseRepository
public MongoExpenseRepository(@NonNull com.mongodb.client.MongoClient mongoClient) Creates mongo repository- Parameters:
mongoClient
- Mongo client to be used
-
-
Method Details
-
saveExpense
Description copied from interface:ExpenseRepository
Saves the expense to storage- Specified by:
saveExpense
in interfaceExpenseRepository
- Parameters:
expense
- Expense saved- Returns:
- expense saved
-
getExpense
Description copied from interface:ExpenseRepository
Finds the expense with given id- Specified by:
getExpense
in interfaceExpenseRepository
- Parameters:
id
- ID as shown by showExpenses- Returns:
- Expense if found else empty
-
getExpenses
Description copied from interface:ExpenseRepository
Finds all the expenses saved- Specified by:
getExpenses
in interfaceExpenseRepository
- Returns:
- List of all the expenses saved
-
changeExpense
Description copied from interface:ExpenseRepository
Changes the expense with given ID- Specified by:
changeExpense
in interfaceExpenseRepository
- Parameters:
id
- ID identifying the expense. It is the left value displayed when calling showExpensesnewAmount
- 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
-