Package io.debezium.relational.history
Class HistoryRecordComparator
- java.lang.Object
-
- io.debezium.relational.history.HistoryRecordComparator
-
public class HistoryRecordComparator extends Object
Compares HistoryRecord instances to determine which came first.- Since:
- 0.2
- Author:
- Randall Hauch
-
-
Field Summary
Fields Modifier and Type Field Description static HistoryRecordComparatorINSTANCEA comparator instance that requires therecords' sourcesto be the same and considers only those fields that are in both records'positions.
-
Constructor Summary
Constructors Constructor Description HistoryRecordComparator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisAtOrBefore(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 Detail
-
INSTANCE
public static final HistoryRecordComparator INSTANCE
A comparator instance that requires therecords' sourcesto be the same and considers only those fields that are in both records'positions.
-
-
Method Detail
-
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
public boolean isAtOrBefore(HistoryRecord record1, HistoryRecord record2)
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
protected boolean isPositionAtOrBefore(Document position1, Document position2)
-
-