Class Money<T extends Money<T>>
java.lang.Object
com.truebubo.maniflow.money.CurrencyTypes.Money<T>
- Type Parameters:
T
- Currency itself. Used for making operation only between the same currency
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Money
(BigDecimal amount, CurrencyDesignation designation) Creates money -
Method Summary
Modifier and TypeMethodDescriptionfinal T
Adds another money with given currencyfinal BigDecimal
amount()
Amount compared to base of currencyfinal CurrencyDesignation
Gets currency designation of money heldabstract T
make
(BigDecimal amount) Used to force children to give us their instancefinal T
multiply
(double multiplier) Multiplies amount by a scalarfinal T
multiply
(long multiplier) Multiplies amount by a scalarfinal T
multiply
(BigDecimal multiplier) Multiplies amount by a scalarfinal <ToCurrency extends Money<ToCurrency>>
ToCurrencyto
(ToCurrency toCurrencyInstance) Converts to another currencyfinal String
toString()
-
Constructor Details
-
Money
Creates money- Parameters:
amount
- Amount compared to basedesignation
- 3 letter code of currency
-
-
Method Details
-
designation
Gets currency designation of money held- Returns:
- designation
-
to
public final <ToCurrency extends Money<ToCurrency>> ToCurrency to(@NonNull ToCurrency toCurrencyInstance) throws ConversionFailedException Converts to another currency- Type Parameters:
ToCurrency
- Currency types we wish to convert to- Parameters:
toCurrencyInstance
- Instance of the currency we want to make this to- Returns:
- this converted to another currency
- Throws:
ConversionFailedException
- Could not be converted
-
amount
-
toString
-
make
Used to force children to give us their instance- Parameters:
amount
- How much of a currency do we own- Returns:
- Money in given currency
-
add
-
multiply
Multiplies amount by a scalar- Parameters:
multiplier
- Multiplied by this value- Returns:
- Increased value by scalar
-
multiply
Multiplies amount by a scalar- Parameters:
multiplier
- Multiplied by this value- Returns:
- Increased value by scalar
-
multiply
Multiplies amount by a scalar- Parameters:
multiplier
- Multiplied by this value- Returns:
- Increased value by scalar
-