Class HistoryRecordComparator


  • public class HistoryRecordComparator
    extends Object
    Compares HistoryRecord instances to determine which came first.
    Since:
    0.2
    Author:
    Randall Hauch
    • Constructor Detail

      • HistoryRecordComparator

        public HistoryRecordComparator()
    • Method Detail

      • usingPositions

        public static HistoryRecordComparator usingPositions​(BiFunction<Document,​Document,​Boolean> positionComparator)
        Create a HistoryRecordComparator that requires identical sources but will use the supplied function to compare positions.
        Parameters:
        positionComparator - the non-null function that returns true if the first position is at or before the second position or false otherwise
        Returns:
        the comparator instance; never null
      • isAtOrBefore

        public boolean isAtOrBefore​(HistoryRecord record1,
                                    HistoryRecord record2)
        Determine if the first HistoryRecord is at the same or earlier point in time than the second HistoryRecord.
        Parameters:
        record1 - the first record; never null
        record2 - the second record; never null
        Returns:
        true if the first record is at the same or earlier point in time than the second record, or false otherwise
      • isPositionAtOrBefore

        protected boolean isPositionAtOrBefore​(Document position1,
                                               Document position2)
      • isSameSource

        protected boolean isSameSource​(Document source1,
                                       Document source2)