Package io.debezium.data
Class SpecialValueDecimal
- java.lang.Object
-
- io.debezium.data.SpecialValueDecimal
-
- All Implemented Interfaces:
Serializable
public class SpecialValueDecimal extends Object implements Serializable
Extension of plain aBigDecimal
type 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 class
SpecialValueDecimal.SpecialValue
Special values for floating-point and numeric types
-
Field Summary
Fields Modifier and Type Field Description private BigDecimal
decimalValue
static SpecialValueDecimal
NEGATIVE_INF
static SpecialValueDecimal
NOT_A_NUMBER
static SpecialValueDecimal
POSITIVE_INF
private static String
PRECISION_PARAMETER_KEY
Used as a schema parameter by the Avro serializer for creating a corresponding Avro schema with the correct precision.private static long
serialVersionUID
private SpecialValueDecimal.SpecialValue
specialValue
static SpecialValueDecimal
ZERO
-
Constructor Summary
Constructors Modifier Constructor Description private
SpecialValueDecimal(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.SchemaBuilder
builder(JdbcValueConverters.DecimalMode mode, int precision, int scale)
Returns aSchemaBuilder
for a decimal number depending onJdbcValueConverters.DecimalMode
.boolean
equals(Object obj)
static Object
fromLogical(SpecialValueDecimal value, JdbcValueConverters.DecimalMode mode, String columnName)
Optional<BigDecimal>
getDecimalValue()
int
hashCode()
double
toDouble()
String
toString()
Converts a value from its logical format (BigDecimal/special) to its string representationstatic SpecialValueDecimal
valueOf(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:
SpecialValueDecimal
containing 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 aSchemaBuilder
for 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)
-
-