public interface SequenceStrategy
extends sirius.kernel.di.std.Named
Modifier and Type | Method and Description |
---|---|
void |
collectKnownSequences(Consumer<String> nameConsumer)
Enumerates the names of all known sequences.
|
long |
peekNextValue(String sequence)
Peeks at the next value in the sequence without using it.
|
void |
setNextValue(String sequence,
long nextValue,
boolean force)
Specifies the next value to use for the given sequence.
|
Long |
tryGenerateId(String sequence)
Tries to generate the next id in the given sequence.
|
Long tryGenerateId(String sequence) throws Exception
sequence
- the sequence to generate the next id forException
- in case of a severe errorlong peekNextValue(String sequence) throws Exception
sequence
- the sequence to determine the next value forException
- in case of a severe errorSequences.peekNextValue(String)
void setNextValue(String sequence, long nextValue, boolean force) throws Exception
Unless force is set to true, the value has to be higher than the current counter value to prevent non unique numbers from being generated.
sequence
- the sequence to updatenextValue
- the next value that will be returned when calling tryGenerateId(String)
for this
sequence.force
- if true, no sanity checks are performed and the sequence can be reset to ANY
value. This is rather dangerous, as it might lead to the generation of duplicate ids. If
set to false, the given nextValue has to be higher than the current sequence
value.Exception
- in case or a severe errorCopyright © 2018. All rights reserved.