Package io.debezium.document
Interface Array
-
- All Superinterfaces:
Comparable<Array>
,Iterable<Array.Entry>
- All Known Implementing Classes:
BasicArray
public interface Array extends Iterable<Array.Entry>, Comparable<Array>
An array ofValue
s. The array can also be viewed as a stream ofArray.Entry
instances, each of which contain the index and the value.- Author:
- Randall Hauch
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Array.Entry
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Array
add(boolean value)
Adds the boolean value to the end of this array.default Array
add(double value)
Adds the double value to the end of this array.default Array
add(float value)
Adds the float value to the end of this array.default Array
add(int value)
Adds the integer value to the end of this array.default Array
add(long value)
Adds the long value to the end of this array.default Array
add(Array value)
Adds the array value to the end of this array.default Array
add(Document value)
Adds the document value to the end of this array.Array
add(Value value)
Adds the value to the end of this array.default Array
add(Boolean value)
Adds the boolean value to the end of this array.default Array
add(Double value)
Adds the double value to the end of this array.default Array
add(Float value)
Adds the float value to the end of this array.default Array
add(Integer value)
Adds the integer value to the end of this array.default Array
add(Long value)
Adds the long value to the end of this array.default Array
add(String value)
Adds the string value to the end of this array.default Array
add(BigDecimal value)
Adds the decimal value to the end of this array.default Array
add(BigInteger value)
Adds the big integer value to the end of this array.default Array
addAll(Value... values)
Sets on this object all name/value pairs from the supplied object.default Array
addAll(Iterable<Value> values)
Sets on this object all name/value pairs from the supplied object.default Array
addAll(Object... values)
Sets on this object all name/value pairs from the supplied object.default Array
addAll(Stream<Value> values)
Sets on this object all name/value pairs from the supplied object.default Array
addNull()
Adds a null value to the end of this array.Array
clone()
Obtain a complete copy of this array.static Array
create()
static Array
create(Value[] values)
static Array
create(Value firstValue, Value secondValue, Value... additionalValues)
static Array
create(Iterable<?> values)
static Array
create(Object... values)
static Array
create(List<Value> values)
static Array
createWithNulls(int number)
default Array
expand(int desiredSize)
If the current size of the array is smaller than the given size, expand it and use a null value for all new entries.default Array
expand(int desiredSize, boolean value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries.default Array
expand(int desiredSize, double value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries.default Array
expand(int desiredSize, float value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries.default Array
expand(int desiredSize, int value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries.default Array
expand(int desiredSize, long value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries.Array
expand(int desiredSize, Value value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries.default Array
expand(int desiredSize, String value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries.Value
get(int index)
Gets the value in this array at the given index.default Value
get(int index, Object defaultValue)
Gets the value in this document for the given field name.boolean
has(int index)
Determine if this contains an entry at the given index.default Array
increment(int index, double increment)
Increment the numeric value at the given location by the designated amount.default Array
increment(int index, float increment)
Increment the numeric value at the given location by the designated amount.default Array
increment(int index, int increment)
Increment the numeric value at the given location by the designated amount.default Array
increment(int index, long increment)
Increment the numeric value at the given location by the designated amount.Array
increment(int index, Value increment)
Increment the numeric value at the given location by the designated amount.boolean
isEmpty()
Return whether this document contains no fields and is therefore empty.default boolean
isNull(int index)
Determine whether this object has an entry at the given index and the value is null.default boolean
isNullOrMissing(int index)
Determine whether this object has an entry at the given index and the value is null, or if this object has no entry at the given index.default Array
putAll(Iterable<Array.Entry> entries)
Sets on this object all key/value pairs from the supplied map.Value
remove(int index)
Remove the specified entry from this arrayArray
removeAll()
Remove all entries from this array.default Array
setArray(int index)
Set the value for the field with the given name to be a new, empty array.default Array
setArray(int index, Array array)
Set the value for the field with the given name to be the supplied array.default Array
setArray(int index, Value... values)
Set the value for the field with the given name to be the supplied array.default Array
setBinary(int index, byte[] data)
Set the value for the field with the given name to be a binary value.default Array
setBoolean(int index, boolean value)
Set the value for the field with the given name to the supplied boolean value.default Document
setDocument(int index)
Set the value for the field with the given name to be a new, empty Document.default Document
setDocument(int index, Document document)
Set the value for the field with the given name to be the supplied Document.default Array
setNull(int index)
Set the value for the field with the given name to be a null value.default Array
setNumber(int index, double value)
Set the value for the field with the given name to the supplied double value.default Array
setNumber(int index, float value)
Set the value for the field with the given name to the supplied float value.default Array
setNumber(int index, int value)
Set the value for the field with the given name to the supplied integer value.default Array
setNumber(int index, long value)
Set the value for the field with the given name to the supplied long value.default Array
setNumber(int index, BigDecimal value)
Set the value for the field with the given name to the supplied big integer value.default Array
setNumber(int index, BigInteger value)
Set the value for the field with the given name to the supplied big integer value.default Array
setString(int index, String value)
Set the value for the field with the given name to the supplied string value.Array
setValue(int index, Value value)
Set the value for the field with the given name to be a value.int
size()
Return the number of name-value fields in this object.default Stream<Array.Entry>
streamEntries()
Returns a sequentialStream
with this array as its source.default Stream<Value>
streamValues()
Returns a sequentialStream
with this array as its source.default Array
transform(BiFunction<Integer,Value,Value> transformer)
Transform all of the field values using the suppliedtransformer function
.default Iterable<Value>
values()
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
create
static Array create()
-
createWithNulls
static Array createWithNulls(int number)
-
size
int size()
Return the number of name-value fields in this object.- Returns:
- the number of name-value fields; never negative
-
isEmpty
boolean isEmpty()
Return whether this document contains no fields and is therefore empty.- Returns:
- true if there are no fields in this document, or false if there is at least one.
-
has
boolean has(int index)
Determine if this contains an entry at the given index.- Parameters:
index
- the index- Returns:
- true if the entry exists, or false otherwise
-
get
Value get(int index)
Gets the value in this array at the given index.- Parameters:
index
- the index- Returns:
- The field value, if found, or null otherwise
-
get
default Value get(int index, Object defaultValue)
Gets the value in this document for the given field name.- Parameters:
index
- the indexdefaultValue
- the default value to return if there is no such entry- Returns:
- The value if found or
defaultValue
if there is no such entry
-
isNull
default boolean isNull(int index)
Determine whether this object has an entry at the given index and the value is null.- Parameters:
index
- the index- Returns:
true
if the entry exists but is null, or false otherwise- See Also:
isNullOrMissing(int)
-
isNullOrMissing
default boolean isNullOrMissing(int index)
Determine whether this object has an entry at the given index and the value is null, or if this object has no entry at the given index.- Parameters:
index
- the index- Returns:
true
if the field value for the name is null or if there is no such field.- See Also:
isNull(int)
-
remove
Value remove(int index)
Remove the specified entry from this array- Parameters:
index
- the index- Returns:
- the value in the removed entry, or null if there is no such entry
-
removeAll
Array removeAll()
Remove all entries from this array.- Returns:
- this array to allow for chaining methods
-
addAll
default Array addAll(Object... values)
Sets on this object all name/value pairs from the supplied object. If the supplied object is null, this method does nothing.- Parameters:
values
- the values to be added to this array- Returns:
- this array to allow for chaining methods
-
addAll
default Array addAll(Value... values)
Sets on this object all name/value pairs from the supplied object. If the supplied object is null, this method does nothing.- Parameters:
values
- the values to be added to this array- Returns:
- this array to allow for chaining methods
-
addAll
default Array addAll(Iterable<Value> values)
Sets on this object all name/value pairs from the supplied object. If the supplied object is null, this method does nothing.- Parameters:
values
- the values to be added to this array- Returns:
- this array to allow for chaining methods
-
addAll
default Array addAll(Stream<Value> values)
Sets on this object all name/value pairs from the supplied object. If the supplied object is null, this method does nothing.- Parameters:
values
- the values to be added to this array- Returns:
- this array to allow for chaining methods
-
add
Array add(Value value)
Adds the value to the end of this array.- Parameters:
value
- the value; may not be null- Returns:
- this array to allow for chaining methods
-
addNull
default Array addNull()
Adds a null value to the end of this array.- Returns:
- this array to allow for chaining methods
-
add
default Array add(String value)
Adds the string value to the end of this array.- Parameters:
value
- the string value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
add
default Array add(boolean value)
Adds the boolean value to the end of this array.- Parameters:
value
- the boolean value; may not be null- Returns:
- this array to allow for chaining methods
-
add
default Array add(Boolean value)
Adds the boolean value to the end of this array.- Parameters:
value
- the boolean value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
add
default Array add(int value)
Adds the integer value to the end of this array.- Parameters:
value
- the integer value; may not be null- Returns:
- this array to allow for chaining methods
-
add
default Array add(long value)
Adds the long value to the end of this array.- Parameters:
value
- the long value; may not be null- Returns:
- this array to allow for chaining methods
-
add
default Array add(float value)
Adds the float value to the end of this array.- Parameters:
value
- the float value; may not be null- Returns:
- this array to allow for chaining methods
-
add
default Array add(double value)
Adds the double value to the end of this array.- Parameters:
value
- the double value; may not be null- Returns:
- this array to allow for chaining methods
-
add
default Array add(BigInteger value)
Adds the big integer value to the end of this array.- Parameters:
value
- the big integer value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
add
default Array add(BigDecimal value)
Adds the decimal value to the end of this array.- Parameters:
value
- the decimal value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
add
default Array add(Integer value)
Adds the integer value to the end of this array.- Parameters:
value
- the integer value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
add
default Array add(Long value)
Adds the long value to the end of this array.- Parameters:
value
- the long value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
add
default Array add(Float value)
Adds the float value to the end of this array.- Parameters:
value
- the float value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
add
default Array add(Double value)
Adds the double value to the end of this array.- Parameters:
value
- the double value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
add
default Array add(Document value)
Adds the document value to the end of this array.- Parameters:
value
- the document value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
add
default Array add(Array value)
Adds the array value to the end of this array.- Parameters:
value
- the array value; may be null if anull value
should be added- Returns:
- this array to allow for chaining methods
-
putAll
default Array putAll(Iterable<Array.Entry> entries)
Sets on this object all key/value pairs from the supplied map. If the supplied map is null, this method does nothing.- Parameters:
entries
- the entries that are to be used to modify this array- Returns:
- this array to allow for chaining methods
-
streamEntries
default Stream<Array.Entry> streamEntries()
Returns a sequentialStream
with this array as its source.- Returns:
- a sequential
Stream
over the elements in this collection
-
streamValues
default Stream<Value> streamValues()
Returns a sequentialStream
with this array as its source.- Returns:
- a sequential
Stream
over the elements in this collection
-
transform
default Array transform(BiFunction<Integer,Value,Value> transformer)
Transform all of the field values using the suppliedtransformer function
.- Parameters:
transformer
- the transformer that should be used to transform each field value; may not be null- Returns:
- this array with transformed fields, or this document if the transformer changed none of the values
-
setNull
default Array setNull(int index)
Set the value for the field with the given name to be a null value. TheisNull(int)
methods can be used to determine if a field has been set to null, orisNullOrMissing(int)
if the field has not be set or if it has been set to null.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
- Returns:
- this array to allow for chaining methods
- See Also:
isNull(int)
,isNullOrMissing(int)
-
setBoolean
default Array setBoolean(int index, boolean value)
Set the value for the field with the given name to the supplied boolean value.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
value
- the new value for the field- Returns:
- this array to allow for chaining methods
-
setNumber
default Array setNumber(int index, int value)
Set the value for the field with the given name to the supplied integer value.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
value
- the new value for the field- Returns:
- this array to allow for chaining methods
-
setNumber
default Array setNumber(int index, long value)
Set the value for the field with the given name to the supplied long value.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
value
- the new value for the field- Returns:
- this array to allow for chaining methods
-
setNumber
default Array setNumber(int index, float value)
Set the value for the field with the given name to the supplied float value.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
value
- the new value for the field- Returns:
- this array to allow for chaining methods
-
setNumber
default Array setNumber(int index, double value)
Set the value for the field with the given name to the supplied double value.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
value
- the new value for the field- Returns:
- this array to allow for chaining methods
-
setNumber
default Array setNumber(int index, BigInteger value)
Set the value for the field with the given name to the supplied big integer value.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
value
- the new value for the field- Returns:
- this array to allow for chaining methods
-
setNumber
default Array setNumber(int index, BigDecimal value)
Set the value for the field with the given name to the supplied big integer value.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
value
- the new value for the field- Returns:
- this array to allow for chaining methods
-
setString
default Array setString(int index, String value)
Set the value for the field with the given name to the supplied string value.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
value
- the new value for the field- Returns:
- this array to allow for chaining methods
-
setBinary
default Array setBinary(int index, byte[] data)
Set the value for the field with the given name to be a binary value. The value will be encoded as Base64.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
data
- the bytes for the binary value- Returns:
- this array to allow for chaining methods
-
setValue
Array setValue(int index, Value value)
Set the value for the field with the given name to be a value.- Parameters:
index
- the index of the field; must be greater than or equal to 0 and less than or equal tosize
value
- the new value- Returns:
- this array to allow for chaining methods
-
expand
default Array expand(int desiredSize)
If the current size of the array is smaller than the given size, expand it and use a null value for all new entries. This method does nothing if the current size is larger than the supplieddesiredSize
.- Parameters:
desiredSize
- the desired size of the array; may be negative- Returns:
- this array to allow for chaining methods
-
expand
Array expand(int desiredSize, Value value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries. This method does nothing if the current size is larger than the supplieddesiredSize
.- Parameters:
desiredSize
- the desired size of the array; may be negativevalue
- the new value for any new entries- Returns:
- this array to allow for chaining methods
-
expand
default Array expand(int desiredSize, boolean value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries. This method does nothing if the current size is larger than the supplieddesiredSize
.- Parameters:
desiredSize
- the desired size of the array; may be negativevalue
- the new value for any new entries- Returns:
- this array to allow for chaining methods
-
expand
default Array expand(int desiredSize, int value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries. This method does nothing if the current size is larger than the supplieddesiredSize
.- Parameters:
desiredSize
- the desired size of the array; may be negativevalue
- the new value for any new entries- Returns:
- this array to allow for chaining methods
-
expand
default Array expand(int desiredSize, long value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries. This method does nothing if the current size is larger than the supplieddesiredSize
.- Parameters:
desiredSize
- the desired size of the array; may be negativevalue
- the new value for any new entries- Returns:
- this array to allow for chaining methods
-
expand
default Array expand(int desiredSize, float value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries. This method does nothing if the current size is larger than the supplieddesiredSize
.- Parameters:
desiredSize
- the desired size of the array; may be negativevalue
- the new value for any new entries- Returns:
- this array to allow for chaining methods
-
expand
default Array expand(int desiredSize, double value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries. This method does nothing if the current size is larger than the supplieddesiredSize
.- Parameters:
desiredSize
- the desired size of the array; may be negativevalue
- the new value for any new entries- Returns:
- this array to allow for chaining methods
-
expand
default Array expand(int desiredSize, String value)
If the current size of the array is smaller than the given size, expand it and use the supplied value for all new entries. This method does nothing if the current size is larger than the supplieddesiredSize
.- Parameters:
desiredSize
- the desired size of the array; may be negativevalue
- the new value for any new entries- Returns:
- this array to allow for chaining methods
-
increment
default Array increment(int index, int increment)
Increment the numeric value at the given location by the designated amount.- Parameters:
index
- the index of the field; must be greater than or equal to 0 and less than or equal tosize
increment
- the amount to increment the existing value; may be negative to decrement- Returns:
- this array to allow for chaining methods
- Throws:
IllegalArgumentException
- if the current value is not a number
-
increment
default Array increment(int index, long increment)
Increment the numeric value at the given location by the designated amount.- Parameters:
index
- the index of the field; must be greater than or equal to 0 and less than or equal tosize
increment
- the amount to increment the existing value; may be negative to decrement- Returns:
- this array to allow for chaining methods
- Throws:
IllegalArgumentException
- if the current value is not a number
-
increment
default Array increment(int index, double increment)
Increment the numeric value at the given location by the designated amount.- Parameters:
index
- the index of the field; must be greater than or equal to 0 and less than or equal tosize
increment
- the amount to increment the existing value; may be negative to decrement- Returns:
- this array to allow for chaining methods
- Throws:
IllegalArgumentException
- if the current value is not a number
-
increment
default Array increment(int index, float increment)
Increment the numeric value at the given location by the designated amount.- Parameters:
index
- the index of the field; must be greater than or equal to 0 and less than or equal tosize
increment
- the amount to increment the existing value; may be negative to decrement- Returns:
- this array to allow for chaining methods
- Throws:
IllegalArgumentException
- if the current value is not a number
-
increment
Array increment(int index, Value increment)
Increment the numeric value at the given location by the designated amount.- Parameters:
index
- the index of the field; must be greater than or equal to 0 and less than or equal tosize
increment
- the amount to increment the existing value; may be negative to decrement- Returns:
- this array to allow for chaining methods
- Throws:
IllegalArgumentException
- if the current value is not a number
-
setDocument
default Document setDocument(int index)
Set the value for the field with the given name to be a new, empty Document.- Parameters:
index
- the index of the field; must be greater than or equal to 0 and less than or equal tosize
- Returns:
- The editable document that was just created; never null
-
setDocument
default Document setDocument(int index, Document document)
Set the value for the field with the given name to be the supplied Document.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
document
- the document- Returns:
- The document that was just set as the value for the named field; never null and may or may not be the same
instance as the supplied
document
.
-
setArray
default Array setArray(int index)
Set the value for the field with the given name to be a new, empty array.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
- Returns:
- The array that was just created; never null
-
setArray
default Array setArray(int index, Array array)
Set the value for the field with the given name to be the supplied array.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
array
- the array- Returns:
- The array that was just set as the value for the named field; never null and may or may not be the same
instance as the supplied
array
.
-
setArray
default Array setArray(int index, Value... values)
Set the value for the field with the given name to be the supplied array.- Parameters:
index
- the index of the field; must be greater than or equal to 0 or less than or equal tosize
values
- the (valid) values for the array- Returns:
- The array that was just set as the value for the named field; never null and may or may not be the same
instance as the supplied
array
.
-
clone
Array clone()
Obtain a complete copy of this array.- Returns:
- the clone of this array; never null
-
-