public final class SequentialIDGenerator extends AbstractIDGenerator
Generates ID
's in numeric sequence.
A simple counter is used.
Every time that nextIdImpl()
is called,
this counter is incremented.
By default, the counter starts at zero.
A user can set the initial value by using the
SequentialIDGenerator(int start)
constructor.
Modifier and Type | Field and Description |
---|---|
private int |
counter
Counter used to assign
ID 's |
Constructor and Description |
---|
SequentialIDGenerator()
Base constructor.
|
SequentialIDGenerator(int start)
Constructor sets the start value for the counter.
|
Modifier and Type | Method and Description |
---|---|
int |
getCount()
Gets the current counter value
|
String |
nextIdImpl()
Increment counter and then return value.
|
getLastId, nextId
public SequentialIDGenerator()
public SequentialIDGenerator(int start)
Note since the counter increments
before returning the next value,
first ID
generated will be one more
than the given start
parameter.
start
- start the counting at this valuepublic String nextIdImpl()
nextIdImpl
in class AbstractIDGenerator
public int getCount()