Interface WrappedToken
- All Superinterfaces:
TrackingToken
- All Known Implementing Classes:
MergedTrackingToken,ReplayToken
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
-
Field Summary
Fields inherited from interface org.axonframework.messaging.eventhandling.processing.streaming.token.TrackingToken
FIRST, LATEST, RESOURCE_KEY -
Method Summary
Modifier and TypeMethodDescriptionstatic TrackingTokenadvance(TrackingToken base, TrackingToken target) advancedTo(TrackingToken newToken) Advance this token to the givennewToken.Returns the token representing the current position in the stream.<R extends TrackingToken>
Optional<R> Retrieve a token of giventokenTypeif it is wrapped by this token.static <R extends TrackingToken>
Optional<R> unwrap(TrackingToken token, Class<R> tokenType) Unwrap the giventokenuntil a token of giventokenTypeis exposed.static TrackingTokenunwrapLowerBound(TrackingToken token) Extracts a raw token describing the current processing position of the giventoken.static TrackingTokenunwrapUpperBound(TrackingToken token) Extracts a raw token describing the current processing position of the giventoken.Returns the token representing the furthest position in the stream described by this token.Methods inherited from interface org.axonframework.messaging.eventhandling.processing.streaming.token.TrackingToken
covers, lowerBound, position, samePositionAs, upperBound
-
Method Details
-
unwrapLowerBound
Extracts a raw token describing the current processing position of the giventoken. 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
Extracts a raw token describing the current processing position of the giventoken. 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
Unwrap the giventokenuntil a token of giventokenTypeis exposed. Returns an empty optional if the giventokenis not a WrappedToken instance, or if it does not wrap a token of expectedtokenType.- Type Parameters:
R- The generic type of the token to reveal- Parameters:
token- The token to unwraptokenType- The type of token to reveal- Returns:
- an optional with the unwrapped token, if found
-
advance
Advance the givenbaseTrackingTokento thetarget. This method will return thetargetas is if thebaseis not an implementation of aWrappedToken. If it is aWrappedToken, it will invokeadvancedTo(TrackingToken)on thebase, using thetarget.- Parameters:
base- theTrackingTokento validate if it's aWrappedTokenwhich can beadvancedTo(TrackingToken)target- theTrackingTokento advance the givenbaseto- Returns:
- the
targetifbasedoes not implementWrappedToken, otherwise the result of invokingadvancedTo(TrackingToken)on thebaseusing thetarget
-
advancedTo
Advance this token to the givennewToken.- 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
Retrieve a token of giventokenTypeif 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
-