Package io.debezium.document
Class BasicDocument
- java.lang.Object
-
- io.debezium.document.BasicDocument
-
- All Implemented Interfaces:
Document
,Comparable<Document>
,Iterable<Document.Field>
@NotThreadSafe final class BasicDocument extends Object implements Document
Package-level implementation ofDocument
.- Author:
- Randall Hauch
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.debezium.document.Document
Document.Field
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static Function<Map.Entry<? extends CharSequence,Value>,Document.Field>
CONVERT_ENTRY_TO_FIELD
private Map<CharSequence,Value>
fields
-
Constructor Summary
Constructors Constructor Description BasicDocument()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Remove all fields from this document.Document
clone()
Obtain a clone of this document.protected int
compare(Value value1, Value value2)
Semantically compare two values.protected int
compareNonNull(Value value1, Value value2)
Semantically compare two non-null values.int
compareTo(Document that)
Compare this Document to the specified Document, taking into account the order of the fields.int
compareTo(Document that, boolean enforceFieldOrder)
Compare this Document to the specified Document, optionally comparing the fields in the same order.int
compareToUsingSimilarFields(Document that)
Compare this Document to the specified Document, without regard to the order of the fields and only using the fields that are in both documents.int
compareToWithoutFieldOrder(Document that)
Compare this Document to the specified Document, without regard to the order of the fields.boolean
equals(Object obj)
Value
get(CharSequence fieldName, Comparable<?> defaultValue)
Gets the value in this document for the given field name.boolean
has(CharSequence fieldName)
Determine if this contains a field with the given name.boolean
hasAll(Document that)
Checks if this object contains all of the fields in the supplied document.int
hashCode()
Document
increment(CharSequence name, Value increment)
Increment the numeric value in the given field by the designated amount.boolean
isEmpty()
Return whether this document contains no fields and is therefore empty.Iterator<Document.Field>
iterator()
Iterable<CharSequence>
keySet()
Returns this object's fields' namesDocument
putAll(Iterable<Document.Field> object)
Sets on this object all name/value pairs from the supplied object.Value
remove(CharSequence name)
Remove the field with the supplied name, and return the value.Document
removeAll()
Remove all fields from this document.Document
setValue(CharSequence name, Value value)
Set the value for the field with the given name.int
size()
Return the number of name-value fields in this object.String
toString()
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.debezium.document.Document
children, children, find, find, forEach, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBytes, getDocument, getDouble, getDouble, getField, getFloat, getFloat, getInteger, getInteger, getLong, getLong, getNumber, getNumber, getOrCreateArray, getOrCreateDocument, getString, getString, increment, increment, increment, increment, isNull, isNullOrMissing, putAll, putAll, putAll, remove, set, set, setArray, setArray, setArray, setBinary, setBoolean, setDocument, setDocument, setNull, setNumber, setNumber, setNumber, setNumber, setNumber, setNumber, setString, setValue, stream, transform
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
CONVERT_ENTRY_TO_FIELD
static final Function<Map.Entry<? extends CharSequence,Value>,Document.Field> CONVERT_ENTRY_TO_FIELD
-
fields
private final Map<CharSequence,Value> fields
-
-
Method Detail
-
size
public int size()
Description copied from interface:Document
Return the number of name-value fields in this object.
-
isEmpty
public boolean isEmpty()
Description copied from interface:Document
Return whether this document contains no fields and is therefore empty.
-
compareTo
public int compareTo(Document that)
Description copied from interface:Document
Compare this Document to the specified Document, taking into account the order of the fields.- Specified by:
compareTo
in interfaceComparable<Document>
- Specified by:
compareTo
in interfaceDocument
- Parameters:
that
- the other Document to be compared to this object- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
compareToUsingSimilarFields
public int compareToUsingSimilarFields(Document that)
Description copied from interface:Document
Compare this Document to the specified Document, without regard to the order of the fields and only using the fields that are in both documents.- Specified by:
compareToUsingSimilarFields
in interfaceDocument
- Parameters:
that
- the other Document to be compared to this object- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
compareToWithoutFieldOrder
public int compareToWithoutFieldOrder(Document that)
Description copied from interface:Document
Compare this Document to the specified Document, without regard to the order of the fields.- Specified by:
compareToWithoutFieldOrder
in interfaceDocument
- Parameters:
that
- the other Document to be compared to this object- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
compareTo
public int compareTo(Document that, boolean enforceFieldOrder)
Description copied from interface:Document
Compare this Document to the specified Document, optionally comparing the fields in the same order.- Specified by:
compareTo
in interfaceDocument
- Parameters:
that
- the other Document to be compared to this objectenforceFieldOrder
-true
if the documents should be compared using their existing field order, orfalse
if the field order should not affect the result.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
compare
protected int compare(Value value1, Value value2)
Semantically compare two values. This includes comparing numeric values of different types (e.g., an integer and long), andnull
andValue.nullValue()
references.- Parameters:
value1
- the first value; may be nullvalue2
- the second value; may be null- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
compareNonNull
protected int compareNonNull(Value value1, Value value2)
Semantically compare two non-null values. This includes comparing numeric values of different types (e.g., an integer and long), but excludesnull
andValue.nullValue()
references.- Parameters:
value1
- the first value; may be nullvalue2
- the second value; may be null- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
keySet
public Iterable<CharSequence> keySet()
Description copied from interface:Document
Returns this object's fields' names
-
iterator
public Iterator<Document.Field> iterator()
- Specified by:
iterator
in interfaceIterable<Document.Field>
-
clear
public void clear()
Description copied from interface:Document
Remove all fields from this document.
-
has
public boolean has(CharSequence fieldName)
Description copied from interface:Document
Determine if this contains a field with the given name.
-
hasAll
public boolean hasAll(Document that)
Description copied from interface:Document
Checks if this object contains all of the fields in the supplied document.
-
get
public Value get(CharSequence fieldName, Comparable<?> defaultValue)
Description copied from interface:Document
Gets the value in this document for the given field name.
-
putAll
public Document putAll(Iterable<Document.Field> object)
Description copied from interface:Document
Sets on this object all name/value pairs from the supplied object. If the supplied object is null, this method does nothing.
-
removeAll
public Document removeAll()
Description copied from interface:Document
Remove all fields from this document.
-
remove
public Value remove(CharSequence name)
Description copied from interface:Document
Remove the field with the supplied name, and return the value.
-
setValue
public Document setValue(CharSequence name, Value value)
Description copied from interface:Document
Set the value for the field with the given name.
-
increment
public Document increment(CharSequence name, Value increment)
Description copied from interface:Document
Increment the numeric value in the given field by the designated amount.
-
clone
public Document clone()
Description copied from interface:Document
Obtain a clone of this document.
-
-