public abstract class AbstractGenerator<T> extends Object implements ValueGenerator<T>
| Modifier and Type | Field and Description |
|---|---|
protected int |
allocationSize
Allocation size
|
protected ValueGenerationBlock<T> |
block
The current block of values that have been reserved.
|
protected int |
initialValue
Initial value (of the first id).
|
protected String |
name
Symbolic name for the sequence.
|
protected Properties |
properties
Properties controlling the generator behaviour.
|
protected boolean |
repositoryExists
Flag for whether we know that the repository exists.
|
| Constructor and Description |
|---|
AbstractGenerator(String name,
Properties props)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
allocate(int additional)
Method to allocate a number of values into the block.
|
protected boolean |
createRepository()
Method to create any needed repository for the values.
|
T |
current()
Accessor for the current value allocated.
|
long |
currentValue()
Accessor for the current element in the sequence as a long.
|
String |
getName()
Accessor for the symbolic name for this generator.
|
T |
next()
Get next value from the reserved block of values.
|
long |
nextValue()
Accessor for the next element in the sequence as a long.
|
protected ValueGenerationBlock<T> |
obtainGenerationBlock()
Get a new block with the default number of ids.
|
protected ValueGenerationBlock<T> |
obtainGenerationBlock(int number)
Get a new block with the specified number of ids.
|
protected boolean |
repositoryExists()
Method to return if the repository already exists.
|
protected boolean |
requiresRepository()
Indicator for whether the generator requires its own repository.
|
protected ValueGenerationBlock<T> |
reserveBlock()
Method to reserve a default sized block of values.
|
protected abstract ValueGenerationBlock<T> |
reserveBlock(long size)
Method to reserve a block of "size" values.
|
protected String name
protected Properties properties
protected int allocationSize
protected int initialValue
protected ValueGenerationBlock<T> block
protected boolean repositoryExists
public AbstractGenerator(String name, Properties props)
name - Symbolic name for this generatorprops - Properties controlling the behaviour of the generator (or null if not required).public String getName()
getName in interface ValueGenerator<T>public T next()
next in interface ValueGenerator<T>public T current()
current in interface ValueGenerator<T>public long nextValue()
nextValue in interface ValueGenerator<T>NucleusDataStoreException - Thrown if not numericpublic long currentValue()
currentValue in interface ValueGenerator<T>NucleusDataStoreException - Thrown if not numericpublic void allocate(int additional)
allocate in interface ValueGenerator<T>additional - The number to allocateprotected ValueGenerationBlock<T> obtainGenerationBlock()
protected ValueGenerationBlock<T> obtainGenerationBlock(int number)
number - The number of additional ids requiredprotected ValueGenerationBlock<T> reserveBlock()
protected abstract ValueGenerationBlock<T> reserveBlock(long size)
size - Number of values to reserveprotected boolean requiresRepository()
protected boolean repositoryExists()
protected boolean createRepository()
Copyright © 2016. All rights reserved.