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
FieldsModifier and TypeFieldDescriptionstatic final HistoryRecordComparatorA comparator instance that requires therecords' sourcesto be the same and considers only those fields that are in both records'positions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisAtOrBefore(HistoryRecord record1, HistoryRecord record2) Determine if the firstHistoryRecordis at the same or earlier point in time than the secondHistoryRecord.protected booleanisPositionAtOrBefore(Document position1, Document position2) protected booleanisSameSource(Document source1, Document source2) static HistoryRecordComparatorusingPositions(BiFunction<Document, Document, Boolean> positionComparator) Create aHistoryRecordComparatorthat requires identical sources but will use the supplied function to compare positions.
-
Field Details
-
INSTANCE
A comparator instance that requires therecords' sourcesto 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 aHistoryRecordComparatorthat requires identical sources but will use the supplied function to compare positions.- Parameters:
positionComparator- the non-null function that returnstrueif the first position is at or before the second position orfalseotherwise- Returns:
- the comparator instance; never null
-
isAtOrBefore
Determine if the firstHistoryRecordis at the same or earlier point in time than the secondHistoryRecord.- Parameters:
record1- the first record; never nullrecord2- the second record; never null- Returns:
trueif the first record is at the same or earlier point in time than the second record, orfalseotherwise
-
isPositionAtOrBefore
-
isSameSource
-