Package io.debezium.document
Interface Value
-
- All Superinterfaces:
Comparable<Value>
- All Known Implementing Classes:
BinaryValue
,ComparableValue
,ConvertingValue
,NullValue
@Immutable public interface Value extends Comparable<Value>
A value in aDocument
orArray
. Note thatcompareTo(io.debezium.document.Value, io.debezium.document.Value)
might perform literal comparisons; to perform semantic comparisons, usecomparable()
to obtain a wrapped value with semantic comparison capability.- Author:
- Randall Hauch
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Value.NullHandler
static class
Value.Type
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Array
asArray()
BigDecimal
asBigDecimal()
BigInteger
asBigInteger()
Boolean
asBoolean()
byte[]
asBytes()
Document
asDocument()
Double
asDouble()
Float
asFloat()
Integer
asInteger()
Long
asLong()
Number
asNumber()
Object
asObject()
Get the raw value.String
asString()
Value
clone()
Obtain a clone of this value.default Value
comparable()
Get a Value representation that will allow semantic comparison of values, rather than the literal comparison normally performed bycompareTo(io.debezium.document.Value, io.debezium.document.Value)
.static int
compareTo(Value value1, Value value2)
Compare twoValue
objects, which may or may not be null.Value
convert()
Get a Value representation that will convert attempt to convert values.static Value
create(boolean value)
static Value
create(byte[] value)
static Value
create(double value)
static Value
create(float value)
static Value
create(int value)
static Value
create(long value)
static Value
create(Array value)
static Value
create(Document value)
static Value
create(Double value)
static Value
create(Float value)
static Value
create(Integer value)
static Value
create(Long value)
static Value
create(Object value)
static Value
create(String value)
static Value
create(BigDecimal value)
static Value
create(BigInteger value)
default Value.Type
getType()
default boolean
ifArray(Consumer<Array> consumer)
If a value is an array, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifBigDecimal(Consumer<BigDecimal> consumer)
If a value is a variable-sized decimal, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifBigInteger(Consumer<BigInteger> consumer)
If a value is a variable-sized integer, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifBinary(Consumer<byte[]> consumer)
If a value is a byte array, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifBoolean(Consumer<Boolean> consumer)
If a value is a boolean value, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifDocument(Consumer<Document> consumer)
If a value is a document, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifDouble(DoubleConsumer consumer)
If a value is a double, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifFloat(DoubleConsumer consumer)
If a value is a float, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifInteger(IntConsumer consumer)
If a value is an integer, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifLong(LongConsumer consumer)
If a value is a long, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifNull(Value.NullHandler consumer)
If a value is a variable-sized integer, invoke the specified consumer with the value, otherwise do nothing.default boolean
ifString(Consumer<String> consumer)
If a value is a string, invoke the specified consumer with the value, otherwise do nothing.boolean
isArray()
boolean
isBigDecimal()
boolean
isBigInteger()
boolean
isBinary()
boolean
isBoolean()
boolean
isDocument()
boolean
isDouble()
boolean
isFloat()
boolean
isInteger()
boolean
isLong()
default boolean
isNotNull()
boolean
isNull()
static boolean
isNull(Value value)
boolean
isNumber()
boolean
isString()
static boolean
isValid(Object value)
static boolean
notNull(Value value)
static Value
nullValue()
-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Method Detail
-
isNull
static boolean isNull(Value value)
-
notNull
static boolean notNull(Value value)
-
isValid
static boolean isValid(Object value)
-
compareTo
static int compareTo(Value value1, Value value2)
Compare twoValue
objects, which may or may not be null.- Parameters:
value1
- the first value object, may be nullvalue2
- the second value object, which may be null- Returns:
- a negative integer if the first value is less than the second, zero if the values are equivalent (including if both are null), or a positive integer if the first value is greater than the second
-
create
static Value create(boolean value)
-
create
static Value create(int value)
-
create
static Value create(long value)
-
create
static Value create(float value)
-
create
static Value create(double value)
-
create
static Value create(BigInteger value)
-
create
static Value create(BigDecimal value)
-
create
static Value create(byte[] value)
-
nullValue
static Value nullValue()
-
getType
default Value.Type getType()
-
asObject
Object asObject()
Get the raw value.- Returns:
- the raw value; may be null
-
asString
String asString()
-
asInteger
Integer asInteger()
-
asLong
Long asLong()
-
asBoolean
Boolean asBoolean()
-
asNumber
Number asNumber()
-
asBigInteger
BigInteger asBigInteger()
-
asBigDecimal
BigDecimal asBigDecimal()
-
asFloat
Float asFloat()
-
asDouble
Double asDouble()
-
asDocument
Document asDocument()
-
asArray
Array asArray()
-
asBytes
byte[] asBytes()
-
isNull
boolean isNull()
-
isNotNull
default boolean isNotNull()
-
isString
boolean isString()
-
isInteger
boolean isInteger()
-
isLong
boolean isLong()
-
isBoolean
boolean isBoolean()
-
isNumber
boolean isNumber()
-
isBigInteger
boolean isBigInteger()
-
isBigDecimal
boolean isBigDecimal()
-
isFloat
boolean isFloat()
-
isDouble
boolean isDouble()
-
isDocument
boolean isDocument()
-
isArray
boolean isArray()
-
isBinary
boolean isBinary()
-
convert
Value convert()
Get a Value representation that will convert attempt to convert values.- Returns:
- a value that can convert actual values to the requested format
-
comparable
default Value comparable()
Get a Value representation that will allow semantic comparison of values, rather than the literal comparison normally performed bycompareTo(io.debezium.document.Value, io.debezium.document.Value)
.- Returns:
- the Value that will perform semantic comparisons; never null
-
clone
Value clone()
Obtain a clone of this value.- Returns:
- the clone of this value; never null, but possibly the same instance if the underlying value is immutable and not a document or array
-
ifDocument
default boolean ifDocument(Consumer<Document> consumer)
If a value is a document, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a document- Returns:
- true if the block was called, or false otherwise
-
ifArray
default boolean ifArray(Consumer<Array> consumer)
If a value is an array, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is an array- Returns:
- true if the block was called, or false otherwise
-
ifString
default boolean ifString(Consumer<String> consumer)
If a value is a string, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a string- Returns:
- true if the block was called, or false otherwise
-
ifBoolean
default boolean ifBoolean(Consumer<Boolean> consumer)
If a value is a boolean value, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a boolean- Returns:
- true if the block was called, or false otherwise
-
ifBinary
default boolean ifBinary(Consumer<byte[]> consumer)
If a value is a byte array, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a byte array- Returns:
- true if the block was called, or false otherwise
-
ifInteger
default boolean ifInteger(IntConsumer consumer)
If a value is an integer, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is an integer- Returns:
- true if the block was called, or false otherwise
-
ifLong
default boolean ifLong(LongConsumer consumer)
If a value is a long, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a long- Returns:
- true if the block was called, or false otherwise
-
ifFloat
default boolean ifFloat(DoubleConsumer consumer)
If a value is a float, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a float- Returns:
- true if the block was called, or false otherwise
-
ifDouble
default boolean ifDouble(DoubleConsumer consumer)
If a value is a double, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a double- Returns:
- true if the block was called, or false otherwise
-
ifBigInteger
default boolean ifBigInteger(Consumer<BigInteger> consumer)
If a value is a variable-sized integer, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a big integer- Returns:
- true if the block was called, or false otherwise
-
ifBigDecimal
default boolean ifBigDecimal(Consumer<BigDecimal> consumer)
If a value is a variable-sized decimal, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a big decimal- Returns:
- true if the block was called, or false otherwise
-
ifNull
default boolean ifNull(Value.NullHandler consumer)
If a value is a variable-sized integer, invoke the specified consumer with the value, otherwise do nothing.- Parameters:
consumer
- block to be executed if the value is a big integer- Returns:
- true if the block was called, or false otherwise
-
-