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 ofValues. The array can also be viewed as a stream ofArray.Entryinstances, each of which contain the index and the value.- Author:
- Randall Hauch
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceArray.Entry
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Arrayadd(boolean value)Adds the boolean value to the end of this array.default Arrayadd(double value)Adds the double value to the end of this array.default Arrayadd(float value)Adds the float value to the end of this array.default Arrayadd(int value)Adds the integer value to the end of this array.default Arrayadd(long value)Adds the long value to the end of this array.default Arrayadd(Array value)Adds the array value to the end of this array.default Arrayadd(Document value)Adds the document value to the end of this array.Arrayadd(Value value)Adds the value to the end of this array.default Arrayadd(Boolean value)Adds the boolean value to the end of this array.default Arrayadd(Double value)Adds the double value to the end of this array.default Arrayadd(Float value)Adds the float value to the end of this array.default Arrayadd(Integer value)Adds the integer value to the end of this array.default Arrayadd(Long value)Adds the long value to the end of this array.default Arrayadd(String value)Adds the string value to the end of this array.default Arrayadd(BigDecimal value)Adds the decimal value to the end of this array.default Arrayadd(BigInteger value)Adds the big integer value to the end of this array.default ArrayaddAll(Value... values)Sets on this object all name/value pairs from the supplied object.default ArrayaddAll(Iterable<Value> values)Sets on this object all name/value pairs from the supplied object.default ArrayaddAll(Object... values)Sets on this object all name/value pairs from the supplied object.default ArrayaddAll(Stream<Value> values)Sets on this object all name/value pairs from the supplied object.default ArrayaddNull()Adds a null value to the end of this array.Arrayclone()Obtain a complete copy of this array.static Arraycreate()static Arraycreate(Value[] values)static Arraycreate(Value firstValue, Value secondValue, Value... additionalValues)static Arraycreate(Iterable<?> values)static Arraycreate(Object... values)static Arraycreate(List<Value> values)static ArraycreateWithNulls(int number)default Arrayexpand(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 Arrayexpand(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 Arrayexpand(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 Arrayexpand(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 Arrayexpand(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 Arrayexpand(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.Arrayexpand(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 Arrayexpand(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.Valueget(int index)Gets the value in this array at the given index.default Valueget(int index, Object defaultValue)Gets the value in this document for the given field name.booleanhas(int index)Determine if this contains an entry at the given index.default Arrayincrement(int index, double increment)Increment the numeric value at the given location by the designated amount.default Arrayincrement(int index, float increment)Increment the numeric value at the given location by the designated amount.default Arrayincrement(int index, int increment)Increment the numeric value at the given location by the designated amount.default Arrayincrement(int index, long increment)Increment the numeric value at the given location by the designated amount.Arrayincrement(int index, Value increment)Increment the numeric value at the given location by the designated amount.booleanisEmpty()Return whether this document contains no fields and is therefore empty.default booleanisNull(int index)Determine whether this object has an entry at the given index and the value is null.default booleanisNullOrMissing(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 ArrayputAll(Iterable<Array.Entry> entries)Sets on this object all key/value pairs from the supplied map.Valueremove(int index)Remove the specified entry from this arrayArrayremoveAll()Remove all entries from this array.default ArraysetArray(int index)Set the value for the field with the given name to be a new, empty array.default ArraysetArray(int index, Array array)Set the value for the field with the given name to be the supplied array.default ArraysetArray(int index, Value... values)Set the value for the field with the given name to be the supplied array.default ArraysetBinary(int index, byte[] data)Set the value for the field with the given name to be a binary value.default ArraysetBoolean(int index, boolean value)Set the value for the field with the given name to the supplied boolean value.default DocumentsetDocument(int index)Set the value for the field with the given name to be a new, empty Document.default DocumentsetDocument(int index, Document document)Set the value for the field with the given name to be the supplied Document.default ArraysetNull(int index)Set the value for the field with the given name to be a null value.default ArraysetNumber(int index, double value)Set the value for the field with the given name to the supplied double value.default ArraysetNumber(int index, float value)Set the value for the field with the given name to the supplied float value.default ArraysetNumber(int index, int value)Set the value for the field with the given name to the supplied integer value.default ArraysetNumber(int index, long value)Set the value for the field with the given name to the supplied long value.default ArraysetNumber(int index, BigDecimal value)Set the value for the field with the given name to the supplied big integer value.default ArraysetNumber(int index, BigInteger value)Set the value for the field with the given name to the supplied big integer value.default ArraysetString(int index, String value)Set the value for the field with the given name to the supplied string value.ArraysetValue(int index, Value value)Set the value for the field with the given name to be a value.intsize()Return the number of name-value fields in this object.default Stream<Array.Entry>streamEntries()Returns a sequentialStreamwith this array as its source.default Stream<Value>streamValues()Returns a sequentialStreamwith this array as its source.default Arraytransform(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
defaultValueif 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:
trueif 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:
trueif 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 valueshould 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 valueshould 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 valueshould 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 valueshould 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 valueshould 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 valueshould 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 valueshould 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 valueshould 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 valueshould 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 valueshould 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 sequentialStreamwith this array as its source.- Returns:
- a sequential
Streamover the elements in this collection
-
streamValues
default Stream<Value> streamValues()
Returns a sequentialStreamwith this array as its source.- Returns:
- a sequential
Streamover 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 tosizevalue- 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 tosizevalue- 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 tosizevalue- 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 tosizevalue- 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 tosizevalue- 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 tosizevalue- 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 tosizevalue- 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 tosizevalue- 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 tosizedata- 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 tosizevalue- 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 tosizeincrement- 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 tosizeincrement- 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 tosizeincrement- 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 tosizeincrement- 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 tosizeincrement- 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 tosizedocument- 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 tosizearray- 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 tosizevalues- 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
-
-