public class SequenceNumberValidator extends Object
Constructor and Description |
---|
SequenceNumberValidator() |
Modifier and Type | Method and Description |
---|---|
Optional<String> |
shardIdFor(String sequenceNumber)
Attempts to retrieve the shardId from a sequence number.
|
Optional<Boolean> |
validateSequenceNumberForShard(String sequenceNumber,
String shardId)
Validates that the sequence number provided contains the given shardId.
|
Optional<Integer> |
versionFor(String sequenceNumber)
Attempts to retrieve the version for a sequence number.
|
public Optional<Integer> versionFor(String sequenceNumber)
This will return an empty Optional if the it's unable to extract the version number. This can occur for
multiple reasons including:
sequenceNumber
- the sequence number to extract the version frompublic Optional<String> shardIdFor(String sequenceNumber)
This should always return a value if versionFor(String)
returns a value
sequenceNumber
- the sequence number to extract the shardId frompublic Optional<Boolean> validateSequenceNumberForShard(String sequenceNumber, String shardId)
Validation of a sequence number will only occur if the sequence number can be parsed. It's possible to use
versionFor(String)
to verify that the given sequence number is supported by this class. There are 3
possible validation states:
Handling unknown validation causes is application specific, and not specific handling is provided.
sequenceNumber
- the sequence number to verify the shardIdshardId
- the shardId that the sequence is expected to containCopyright © 2022. All rights reserved.