Class SpecialValueDecimal

java.lang.Object
io.debezium.data.SpecialValueDecimal
All Implemented Interfaces:
ValueWrapper<BigDecimal>, Serializable

public class SpecialValueDecimal extends Object implements Serializable, ValueWrapper<BigDecimal>
Extension of plain a BigDecimal type that adds support for new features like special values handling - NaN, infinity;
Author:
Jiri Pechanec
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getDecimalValue

      public Optional<BigDecimal> getDecimalValue()
      Returns:
      the plain decimal value if available
    • valueOf

      public static SpecialValueDecimal valueOf(String decimal)
      Factory method for creating instances from numbers in string format
      Parameters:
      decimal - a string containing valid decimal number
      Returns:
      SpecialValueDecimal containing converted BigDecimal
    • toDouble

      public double toDouble()
      Returns:
      value converted into double including special values
    • toString

      public String toString()
      Converts a value from its logical format (BigDecimal/special) to its string representation
      Overrides:
      toString in class Object
      Parameters:
      struct - the strut to put data in
      Returns:
      the encoded value
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • builder

      public static org.apache.kafka.connect.data.SchemaBuilder builder(JdbcValueConverters.DecimalMode mode, int precision, int scale)
      Returns a SchemaBuilder for a decimal number depending on JdbcValueConverters.DecimalMode. You can use the resulting schema builder to set additional schema settings such as required/optional, default value, and documentation.
      Parameters:
      mode - the mode in which the number should be encoded
      precision - the precision of the decimal
      scale - scale of the decimal
      Returns:
      the schema builder
    • fromLogical

      public static Object fromLogical(SpecialValueDecimal value, JdbcValueConverters.DecimalMode mode, String columnName)
    • getWrappedValue

      public BigDecimal getWrappedValue()
      Specified by:
      getWrappedValue in interface ValueWrapper<BigDecimal>