Package io.debezium.relational.history
Class HistoryRecordComparator
java.lang.Object
io.debezium.relational.history.HistoryRecordComparator
Compares HistoryRecord instances to determine which came first.
- Since:
- 0.2
- Author:
- Randall Hauch
-
Field Summary
Modifier and TypeFieldDescriptionstatic final HistoryRecordComparator
A comparator instance that requires therecords' sources
to be the same and considers only those fields that are in both records'positions
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
isAtOrBefore
(HistoryRecord record1, HistoryRecord record2) Determine if the firstHistoryRecord
is at the same or earlier point in time than the secondHistoryRecord
.protected boolean
isPositionAtOrBefore
(Document position1, Document position2) protected boolean
isSameSource
(Document source1, Document source2) static HistoryRecordComparator
usingPositions
(BiFunction<Document, Document, Boolean> positionComparator) Create aHistoryRecordComparator
that requires identical sources but will use the supplied function to compare positions.
-
Field Details
-
INSTANCE
A comparator instance that requires therecords' sources
to be the same and considers only those fields that are in both records'positions
.
-
-
Constructor Details
-
HistoryRecordComparator
public HistoryRecordComparator()
-
-
Method Details
-
usingPositions
public static HistoryRecordComparator usingPositions(BiFunction<Document, Document, Boolean> positionComparator) Create aHistoryRecordComparator
that requires identical sources but will use the supplied function to compare positions.- Parameters:
positionComparator
- the non-null function that returnstrue
if the first position is at or before the second position orfalse
otherwise- Returns:
- the comparator instance; never null
-
isAtOrBefore
Determine if the firstHistoryRecord
is at the same or earlier point in time than the secondHistoryRecord
.- Parameters:
record1
- the first record; never nullrecord2
- the second record; never null- Returns:
true
if the first record is at the same or earlier point in time than the second record, orfalse
otherwise
-
isPositionAtOrBefore
-
isSameSource
-