public class Wallet
extends TransactionHolderModel
Models a Wallet in the database
Modifier and Type | Class and Description |
---|---|
static class |
Wallet.Companion
Static Methods
|
Modifier and Type | Field and Description |
---|---|
static Wallet.Companion |
Companion
Static Methods
|
Constructor and Description |
---|
Wallet(int id,
java.lang.String name,
Value startingValue)
Models a Wallet in the database
|
Modifier and Type | Method and Description |
---|---|
void |
convertCurrency(DbHandler dbHandler,
Currency currency)
Converts the currency of the wallet. All transaction values in the wallet will also be converted.
|
boolean |
equals(java.lang.Object other)
Checks for equality with another object
|
static Wallet |
fromResultSet(java.sql.ResultSet resultSet)
Generates a Wallet object from a ResultSet
|
static Wallet |
get(DbHandler dbHandler,
int id)
Retrieves a Wallet from the database by its ID
|
static Wallet |
get(DbHandler dbHandler,
java.lang.String nameOrId)
Retrieves a Wallet from the database by its name or ID
|
Value |
getBalance(DbHandler dbHandler)
Calculates the balance of all transactions
|
Currency |
getCurrency()
Retrieves the currency currently used within this wallet
|
java.lang.String |
toString()
Represents the wallet as a String
|
java.lang.String |
toString(DbHandler dbHandler)
Represents the wallet as String including the current balance
|
getTransactions
createHelper, getName, toString
public static Wallet.Companion Companion
Static Methods
public Wallet(int id, java.lang.String name, Value startingValue)
Models a Wallet in the database
id
- : The ID of the wallet in the databasename
- : The name of the walletid
- : The ID of the wallet in the databasename
- : The name of the walletpublic Value getBalance(DbHandler dbHandler)
Calculates the balance of all transactions
dbHandler
- : The database handler to usepublic Currency getCurrency()
Retrieves the currency currently used within this wallet
public void convertCurrency(DbHandler dbHandler, Currency currency)
Converts the currency of the wallet. All transaction values in the wallet will also be converted.
public java.lang.String toString()
Represents the wallet as a String
public java.lang.String toString(DbHandler dbHandler)
Represents the wallet as String including the current balance
dbHandler
- : The database handler used to retrieve the transactions for calculating the balancepublic boolean equals(java.lang.Object other)
Checks for equality with another object
other
- : The other objectpublic static Wallet fromResultSet(java.sql.ResultSet resultSet)
Generates a Wallet object from a ResultSet
resultSet
- : The ResultSet to use to generate the Wallet objectpublic static Wallet get(DbHandler dbHandler, int id)
Retrieves a Wallet from the database by its ID
dbHandler
- : The database handler to useid
- : The ID of the Walletpublic static Wallet get(DbHandler dbHandler, java.lang.String nameOrId)
Retrieves a Wallet from the database by its name or ID
dbHandler
- : The database handler to usenameOrId
- : The name or ID of the Wallet