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_FIELDprivate Map<CharSequence,Value>fields
-
Constructor Summary
Constructors Constructor Description BasicDocument()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Remove all fields from this document.Documentclone()Obtain a clone of this document.protected intcompare(Value value1, Value value2)Semantically compare two values.protected intcompareNonNull(Value value1, Value value2)Semantically compare two non-null values.intcompareTo(Document that)Compare this Document to the specified Document, taking into account the order of the fields.intcompareTo(Document that, boolean enforceFieldOrder)Compare this Document to the specified Document, optionally comparing the fields in the same order.intcompareToUsingSimilarFields(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.intcompareToWithoutFieldOrder(Document that)Compare this Document to the specified Document, without regard to the order of the fields.booleanequals(Object obj)Valueget(CharSequence fieldName, Comparable<?> defaultValue)Gets the value in this document for the given field name.booleanhas(CharSequence fieldName)Determine if this contains a field with the given name.booleanhasAll(Document that)Checks if this object contains all of the fields in the supplied document.inthashCode()Documentincrement(CharSequence name, Value increment)Increment the numeric value in the given field by the designated amount.booleanisEmpty()Return whether this document contains no fields and is therefore empty.Iterator<Document.Field>iterator()Iterable<CharSequence>keySet()Returns this object's fields' namesDocumentputAll(Iterable<Document.Field> object)Sets on this object all name/value pairs from the supplied object.Valueremove(CharSequence name)Remove the field with the supplied name, and return the value.DocumentremoveAll()Remove all fields from this document.DocumentsetValue(CharSequence name, Value value)Set the value for the field with the given name.intsize()Return the number of name-value fields in this object.StringtoString()-
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:DocumentReturn the number of name-value fields in this object.
-
isEmpty
public boolean isEmpty()
Description copied from interface:DocumentReturn whether this document contains no fields and is therefore empty.
-
compareTo
public int compareTo(Document that)
Description copied from interface:DocumentCompare this Document to the specified Document, taking into account the order of the fields.- Specified by:
compareToin interfaceComparable<Document>- Specified by:
compareToin 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:DocumentCompare 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:
compareToUsingSimilarFieldsin 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:DocumentCompare this Document to the specified Document, without regard to the order of the fields.- Specified by:
compareToWithoutFieldOrderin 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:DocumentCompare this Document to the specified Document, optionally comparing the fields in the same order.- Specified by:
compareToin interfaceDocument- Parameters:
that- the other Document to be compared to this objectenforceFieldOrder-trueif the documents should be compared using their existing field order, orfalseif 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), andnullandValue.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 excludesnullandValue.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:DocumentReturns this object's fields' names
-
iterator
public Iterator<Document.Field> iterator()
- Specified by:
iteratorin interfaceIterable<Document.Field>
-
clear
public void clear()
Description copied from interface:DocumentRemove all fields from this document.
-
has
public boolean has(CharSequence fieldName)
Description copied from interface:DocumentDetermine if this contains a field with the given name.
-
hasAll
public boolean hasAll(Document that)
Description copied from interface:DocumentChecks if this object contains all of the fields in the supplied document.
-
get
public Value get(CharSequence fieldName, Comparable<?> defaultValue)
Description copied from interface:DocumentGets the value in this document for the given field name.
-
putAll
public Document putAll(Iterable<Document.Field> object)
Description copied from interface:DocumentSets 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:DocumentRemove all fields from this document.
-
remove
public Value remove(CharSequence name)
Description copied from interface:DocumentRemove the field with the supplied name, and return the value.
-
setValue
public Document setValue(CharSequence name, Value value)
Description copied from interface:DocumentSet the value for the field with the given name.
-
increment
public Document increment(CharSequence name, Value increment)
Description copied from interface:DocumentIncrement the numeric value in the given field by the designated amount.
-
clone
public Document clone()
Description copied from interface:DocumentObtain a clone of this document.
-
-