java.lang.Object
org.axonframework.messaging.eventhandling.processing.streaming.token.TrackingTokenUtils

public abstract class TrackingTokenUtils extends Object
Utility methods to combine collections of TrackingTokens.

Where TrackingToken.lowerBound(TrackingToken) and TrackingToken.upperBound(TrackingToken) combine two tokens, these helpers reduce an arbitrary collection to a single token, ignoring null elements.

Since:
5.3.0
Author:
Allard Buijze
  • Method Details

    • lowerBound

      public static TrackingToken lowerBound(Collection<@Nullable TrackingToken> tokens)
      Reduces the given tokens to their lowerBound, ignoring any null elements.
      Parameters:
      tokens - the tokens to combine
      Returns:
      the lower bound of the non-null tokens, or TrackingToken.FIRST if there are none
    • upperBound

      public static @Nullable TrackingToken upperBound(Collection<@Nullable TrackingToken> tokens)
      Reduces the given tokens to their upperBound, ignoring any null elements.
      Parameters:
      tokens - the tokens to combine
      Returns:
      the upper bound of the non-null tokens, or null if there are none
    • coversWhenUnwrapped

      public static boolean coversWhenUnwrapped(TrackingToken candidate, TrackingToken reference)
      Indicates whether candidate represents a position at or beyond reference, comparing the raw unwrapped lower-bound and upper-bound positions rather than the tokens directly.

      A wrapped token may describe a range, of which both ends must cover reference to count as an advance. An unwrapped end that is absent on candidate is never an advance; absent on reference it leaves nothing to regress from.

      Parameters:
      candidate - the token whose position is tested
      reference - the token to compare against
      Returns:
      true if both ends of candidate cover the matching ends of reference once unwrapped to their raw positions