protected synchronized List < Message > getAllMessages ( final Follower follower ) { final int end = this . getEndingMessageId ( follower ) ; /* * If messages have been discarded, the original starting message ID * will no longer be valid. Therefore, we check for the actual starting * ID. */ final int start = Math . max ( this . messages . getFirstPosition ( ) , this . getStartingMessageId ( follower ) ) ; if ( start > end ) { /* * in case some messages have been discarded, the actual start may * get ahead of the expected end. this would have caused an * exception within the message store, and so we handle it here and * return an empty list. this is exactly correct, as if the end is * before the first message in the store, there really is nothing to * return. */ return Collections . unmodifiableList ( Collections . emptyList ( ) ) ; } else { return Collections . unmodifiableList ( this . messages . getFromRange ( start , end + 1 ) ) ; } }
Return all messages that have been sent to the follower from its start until either its termination or to this moment whichever is relevant .