private Set < Integer > matchWithClosestAisMessageIfBufferLargeEnough ( long arrivalTime , Integer earliestTimestampLineIndex ) { String timestampLine = getLine ( earliestTimestampLineIndex ) ; long time = getLineTime ( earliestTimestampLineIndex ) ; log . debug ( "ts=" + timestampLine + ",time=" + time ) ; Set < Integer > removeThese ; if ( arrivalTime - time > MAXIMUM_ARRIVAL_TIME_DIFFERENCE_MS ) { removeThese = matchWithClosestAisMessageAndFindIndexesToRemove ( earliestTimestampLineIndex , timestampLine , time ) ; } else removeThese = findExpiredIndexesBeforeIndex ( earliestTimestampLineIndex ) ; return removeThese ; }
Finds matches and reports them to the listeners if buffer has a sufficent span of time in it . Returns the indexes that should be removed from the buffer .