public class MongoSequenceStrategy extends Object implements SequenceStrategy
Sequences| Modifier and Type | Field and Description | 
|---|---|
static String | 
TYPE
Contains the name of this strategy. 
 | 
| Constructor and Description | 
|---|
MongoSequenceStrategy()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
collectKnownSequences(Consumer<String> nameConsumer)
Enumerates the names of all known sequences. 
 | 
String | 
getName()  | 
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. 
 | 
public static final String TYPE
@Nonnull public String getName()
getName in interface sirius.kernel.di.std.Namedpublic Long tryGenerateId(String sequence) throws Exception
SequenceStrategytryGenerateId in interface SequenceStrategysequence - the sequence to generate the next id forException - in case of a severe errorpublic long peekNextValue(String sequence)
SequenceStrategypeekNextValue in interface SequenceStrategysequence - the sequence to determine the next value forSequences.peekNextValue(String)public void setNextValue(String sequence, long nextValue, boolean force)
SequenceStrategyUnless force is set to true, the value has to be higher than the current counter value to prevent non unique numbers from being generated.
setNextValue in interface SequenceStrategysequence - the sequence to updatenextValue - the next  value that will be returned when calling SequenceStrategy.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.public void collectKnownSequences(Consumer<String> nameConsumer) throws Exception
SequenceStrategycollectKnownSequences in interface SequenceStrategynameConsumer - the consumer to be supplied with the namesException - in case or a severe errorCopyright © 2018. All rights reserved.