Class FixedScaleDecimal

    • Method Detail

      • of

        public static FixedScaleDecimal of​(Decimal decimal,
                                           int fixedScale)
        Obtains an instance from a decimal and scale.
        Parameters:
        decimal - the underlying decimal
        fixedScale - the fixed scale, equal or greater than the scale of the decimal
        Returns:
        the equivalent decimal
      • decimal

        public Decimal decimal()
        Gets the underlying decimal.

        The decimal may have a smaller scale, but it will not have a larger scale.

        Returns:
        the decimal
      • fixedScale

        public int fixedScale()
        Gets the fixed scale.
        Returns:
        the fixed scale, from 0 to 18
      • map

        public FixedScaleDecimal map​(UnaryOperator<Decimal> fn)
        Maps this value using the maths operations of Decimal.

        The result must have a scale equal or less than the fixed scale.

        Parameters:
        fn - the function to apply
        Returns:
        the result of the function
        Throws:
        IllegalArgumentException - if the result is too large
      • toBigDecimal

        public BigDecimal toBigDecimal()
        Gets the value as a BigDecimal with the fixed scale.
        Returns:
        the decimal, with a scale equal to the fixed scale
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Returns the formal string representation of the fixed scale decimal.
        Overrides:
        toString in class Object
        Returns:
        the plain string