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 HistoryRecordComparator
INSTANCE
A comparator instance that requires therecords' sources
to 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 boolean
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 Detail
-
INSTANCE
public static final HistoryRecordComparator INSTANCE
A comparator instance that requires therecords' sources
to 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 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
public boolean isAtOrBefore(HistoryRecord record1, HistoryRecord record2)
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
protected boolean isPositionAtOrBefore(Document position1, Document position2)
-
-