Class Decimal

java.lang.Object
org.apache.gravitino.rel.types.Decimal

public class Decimal extends Object
Used to represent a Types.DecimalType value in Apache Gravitino.

For Decimal, we expect the precision is equal to or larger than the scale, however, in BigDecimal, the digit count starts from the leftmost nonzero digit of the exact result. For example, the precision of 0.01 equals to 1 based on the definition, but the scale is 2. The expected precision should be 2.

  • Method Details

    • of

      public static Decimal of(BigDecimal value, int precision, int scale)
      Creates a decimal value with the given value, precision and scale.
      Parameters:
      value - The value of the decimal.
      precision - The precision of the decimal.
      scale - The scale of the decimal.
      Returns:
      A new Decimal instance.
    • of

      public static Decimal of(BigDecimal value)
      Creates a decimal value with the given value.
      Parameters:
      value - The value of the decimal.
      Returns:
      A new Decimal instance.
    • of

      public static Decimal of(String value)
      Creates a decimal value with the given value.
      Parameters:
      value - The value of the decimal.
      Returns:
      A new Decimal instance.
    • of

      public static Decimal of(String value, int precision, int scale)
      Creates a decimal value with the given value, precision and scale.
      Parameters:
      value - The value of the decimal.
      precision - The precision of the decimal.
      scale - The scale of the decimal.
      Returns:
      A new Decimal instance.
    • value

      public BigDecimal value()
      Returns:
      The value of the decimal.
    • precision

      public int precision()
      Returns:
      The precision of the decimal.
    • scale

      public int scale()
      Returns:
      The scale of the decimal.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object