Package io.debezium.data
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 aBigDecimaltype that adds support for new features like special values handling - NaN, infinity;- Author:
- Jiri Pechanec
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSpecialValueDecimal.SpecialValueSpecial values for floating-point and numeric types
-
Field Summary
Fields Modifier and Type Field Description private BigDecimaldecimalValuestatic SpecialValueDecimalNEGATIVE_INFstatic SpecialValueDecimalNOT_A_NUMBERstatic SpecialValueDecimalPOSITIVE_INFprivate static StringPRECISION_PARAMETER_KEYUsed as a schema parameter by the Avro serializer for creating a corresponding Avro schema with the correct precision.private static longserialVersionUIDprivate SpecialValueDecimal.SpecialValuespecialValuestatic SpecialValueDecimalZERO
-
Constructor Summary
Constructors Modifier Constructor Description privateSpecialValueDecimal(SpecialValueDecimal.SpecialValue specialValue)SpecialValueDecimal(BigDecimal value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.apache.kafka.connect.data.SchemaBuilderbuilder(JdbcValueConverters.DecimalMode mode, int precision, int scale)Returns aSchemaBuilderfor a decimal number depending onJdbcValueConverters.DecimalMode.booleanequals(Object obj)static ObjectfromLogical(SpecialValueDecimal value, JdbcValueConverters.DecimalMode mode, String columnName)Optional<BigDecimal>getDecimalValue()BigDecimalgetWrappedValue()inthashCode()doubletoDouble()StringtoString()Converts a value from its logical format (BigDecimal/special) to its string representationstatic SpecialValueDecimalvalueOf(String decimal)Factory method for creating instances from numbers in string format
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
PRECISION_PARAMETER_KEY
private static final String PRECISION_PARAMETER_KEY
Used as a schema parameter by the Avro serializer for creating a corresponding Avro schema with the correct precision.- See Also:
- Constant Field Values
-
ZERO
public static SpecialValueDecimal ZERO
-
NOT_A_NUMBER
public static SpecialValueDecimal NOT_A_NUMBER
-
POSITIVE_INF
public static SpecialValueDecimal POSITIVE_INF
-
NEGATIVE_INF
public static SpecialValueDecimal NEGATIVE_INF
-
decimalValue
private final BigDecimal decimalValue
-
specialValue
private final SpecialValueDecimal.SpecialValue specialValue
-
-
Constructor Detail
-
SpecialValueDecimal
public SpecialValueDecimal(BigDecimal value)
-
SpecialValueDecimal
private SpecialValueDecimal(SpecialValueDecimal.SpecialValue specialValue)
-
-
Method Detail
-
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:
SpecialValueDecimalcontaining convertedBigDecimal
-
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
-
builder
public static org.apache.kafka.connect.data.SchemaBuilder builder(JdbcValueConverters.DecimalMode mode, int precision, int scale)
Returns aSchemaBuilderfor a decimal number depending onJdbcValueConverters.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 encodedprecision- the precision of the decimalscale- 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:
getWrappedValuein interfaceValueWrapper<BigDecimal>
-
-