Class DefaultRoundingStrategy

    • Constructor Detail

      • DefaultRoundingStrategy

        public DefaultRoundingStrategy()
    • Method Detail

      • divide

        public Money divide​(Money price,
                            java.math.BigDecimal divisor)
        Description copied from interface: RoundingStrategy
        Divide price by factor
        Specified by:
        divide in interface RoundingStrategy
        Parameters:
        price - to divide for
        divisor - to divide by
        Returns:
        result of dividing
      • multiply

        public Money multiply​(Money price,
                              java.math.BigDecimal multiplicant)
        Description copied from interface: RoundingStrategy
        Multiply the given money by given factor. The returned Money is the nearest result (rounded up/down) to the calculation.
        Specified by:
        multiply in interface RoundingStrategy
        Parameters:
        price - to multiple for
        multiplicant - to multiple by
        Returns:
        result of multiplying
      • getPercentValue

        public Money getPercentValue​(Money price,
                                     Percentage percent)
        Description copied from interface: RoundingStrategy
        Returns for the given Percentage amount the calculated amount in Money. E.g. 25% of 10.01Euro result in 2.50euro
        Specified by:
        getPercentValue in interface RoundingStrategy
        Parameters:
        price - the price
        percent - the percentage of the price to take.
        Returns:
        A Money object representing a percentage of the price.
      • roundToMoney

        public Money roundToMoney​(java.math.BigDecimal amount,
                                  Currency currency)
        Description copied from interface: RoundingStrategy
        Creates a Money object based on the given BigDecimal amount. Based on the implementation the amount is round up/down to fit into the money.
        Specified by:
        roundToMoney in interface RoundingStrategy
        Parameters:
        amount - the amount to be converted
        currency - based on the currency digits the amount is round up/down
        Returns:
        the neares Money object for the given amount.
      • createMoney

        protected Money createMoney​(java.math.BigDecimal amount,
                                    Currency curr)