Class DecimalData

    • Method Detail

      • precision

        public int precision()
        Returns the precision of this DecimalData.

        The precision is the number of digits in the unscaled value.

      • scale

        public int scale()
        Returns the scale of this DecimalData.
      • toUnscaledBytes

        public byte[] toUnscaledBytes()
        Returns a byte array describing the unscaled value of this DecimalData.
        Returns:
        the unscaled byte array of this DecimalData.
      • isCompact

        public boolean isCompact()
        Returns whether the decimal value is small enough to be stored in a long.
      • hashCode

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

        @Nullable
        public static DecimalData fromBigDecimal​(BigDecimal bd,
                                                 int precision,
                                                 int scale)
        Creates an instance of DecimalData from a BigDecimal and the given precision and scale.

        The returned decimal value may be rounded to have the desired scale. The precision will be checked. If the precision overflows, null will be returned.

      • fromUnscaledLong

        public static DecimalData fromUnscaledLong​(long unscaledLong,
                                                   int precision,
                                                   int scale)
        Creates an instance of DecimalData from an unscaled long value and the given precision and scale.
      • fromUnscaledBytes

        public static DecimalData fromUnscaledBytes​(byte[] unscaledBytes,
                                                    int precision,
                                                    int scale)
        Creates an instance of DecimalData from an unscaled byte array value and the given precision and scale.
      • zero

        @Nullable
        public static DecimalData zero​(int precision,
                                       int scale)
        Creates an instance of DecimalData for a zero value with the given precision and scale.

        The precision will be checked. If the precision overflows, null will be returned.

      • isCompact

        public static boolean isCompact​(int precision)
        Returns whether the decimal value is small enough to be stored in a long.