Interface RoundingStrategy
- All Known Implementing Classes:
DefaultRoundingStrategy,DefaultTaxRoundingStrategy
public interface RoundingStrategy
-
Method Summary
Modifier and TypeMethodDescriptiondivide(Money money, BigDecimal factor) Divide price by factorgetPercentValue(Money price, Percentage percent) Returns for the givenPercentageamount the calculated amount inMoney.multiply(Money money, BigDecimal factor) Multiply the given money by given factor.roundToMoney(BigDecimal amount, Currency currency) Creates aMoneyobject based on the given BigDecimal amount.
-
Method Details
-
divide
Divide price by factor- Parameters:
money- to divide forfactor- to divide by- Returns:
- result of dividing
-
multiply
Multiply the given money by given factor. The returned Money is the nearest result (rounded up/down) to the calculation.- Parameters:
money- to multiple forfactor- to multiple by- Returns:
- result of multiplying
-
getPercentValue
Returns for the givenPercentageamount the calculated amount inMoney. E.g. 25% of 10.01Euro result in 2.50euro- Parameters:
price- the pricepercent- the percentage of the price to take.- Returns:
- A Money object representing a percentage of the price.
-
roundToMoney
Creates aMoneyobject based on the given BigDecimal amount. Based on the implementation the amount is round up/down to fit into the money.- Parameters:
amount- the amount to be convertedcurrency- based on the currency digits the amount is round up/down- Returns:
- the neares Money object for the given amount.
-