All Superinterfaces:
TrackingToken
All Known Implementing Classes:
MergedTrackingToken, ReplayToken

public interface WrappedToken extends TrackingToken
Interface marking a token that wraps another token. As certain implementations may depend on specific token types, Tokens that wrap another must provide a means to retrieve the original token.
Since:
3.2
Author:
Allard Buijze
  • Method Details

    • unwrapLowerBound

      static TrackingToken unwrapLowerBound(TrackingToken token)
      Extracts a raw token describing the current processing position of the given token. If the given token is a wrapped token, it will be unwrapped until the raw token (as received from the event stream) is reached.

      The returned token represents the minimal position described by the given token (which may express a range)

      Parameters:
      token - The token to unwrap
      Returns:
      the raw lower bound token described by given token
    • unwrapUpperBound

      static TrackingToken unwrapUpperBound(TrackingToken token)
      Extracts a raw token describing the current processing position of the given token. If the given token is a wrapped token, it will be unwrapped until the raw token (as received from the event stream) is reached.

      The returned token represents the furthest position described by the given token (which may express a range)

      Parameters:
      token - The token to unwrap
      Returns:
      the raw upper bound token described by given token
    • unwrap

      static <R extends TrackingToken> Optional<R> unwrap(TrackingToken token, Class<R> tokenType)
      Unwrap the given token until a token of given tokenType is exposed. Returns an empty optional if the given token is not a WrappedToken instance, or if it does not wrap a token of expected tokenType.
      Type Parameters:
      R - The generic type of the token to reveal
      Parameters:
      token - The token to unwrap
      tokenType - The type of token to reveal
      Returns:
      an optional with the unwrapped token, if found
    • advance

      static TrackingToken advance(TrackingToken base, TrackingToken target)
      Advance the given base TrackingToken to the target. This method will return the target as is if the base is not an implementation of a WrappedToken. If it is a WrappedToken, it will invoke advancedTo(TrackingToken) on the base, using the target.
      Parameters:
      base - the TrackingToken to validate if it's a WrappedToken which can be advancedTo(TrackingToken)
      target - the TrackingToken to advance the given base to
      Returns:
      the target if base does not implement WrappedToken, otherwise the result of invoking advancedTo(TrackingToken) on the base using the target
    • advancedTo

      TrackingToken advancedTo(TrackingToken newToken)
      Advance this token to the given newToken.
      Parameters:
      newToken - The token representing the position to advance to
      Returns:
      a token representing the new position
    • lowerBound

      TrackingToken lowerBound()
      Returns the token representing the current position in the stream.
      Returns:
      the token representing the current position in the stream
    • upperBound

      TrackingToken upperBound()
      Returns the token representing the furthest position in the stream described by this token. This is usually a position that has been (partially) processed before.
      Returns:
      the token representing the furthest position reached in the stream
    • unwrap

      <R extends TrackingToken> Optional<R> unwrap(Class<R> tokenType)
      Retrieve a token of given tokenType if it is wrapped by this token.
      Type Parameters:
      R - The generic type of the token to unwrap to
      Parameters:
      tokenType - The type of token to unwrap to
      Returns:
      an optional with the unwrapped token, if found