public abstract class AbstractGenerator extends Object implements ValueGenerator
Modifier and Type | Field and Description |
---|---|
protected int |
allocationSize
Allocation size
|
protected ValueGenerationBlock |
block
The current block of values that have been reserved.
|
protected int |
initialValue
Initial value (of the first id).
|
protected static Localiser |
LOCALISER
Localisation of messages
|
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.
|
Object |
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.
|
static Class |
getStorageClass()
Accessor for the storage class for values generated with this generator.
|
Object |
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 |
obtainGenerationBlock()
Get a new block with the default number of ids.
|
protected ValueGenerationBlock |
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 |
reserveBlock()
Method to reserve a default sized block of values.
|
protected abstract ValueGenerationBlock |
reserveBlock(long size)
Method to reserve a block of "size" values.
|
protected static final Localiser LOCALISER
protected String name
protected Properties properties
protected int allocationSize
protected int initialValue
protected ValueGenerationBlock 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 static Class getStorageClass()
public String getName()
getName
in interface ValueGenerator
public Object next()
next
in interface ValueGenerator
public Object current()
current
in interface ValueGenerator
public long nextValue()
nextValue
in interface ValueGenerator
NucleusDataStoreException
- Thrown if not numericpublic long currentValue()
currentValue
in interface ValueGenerator
NucleusDataStoreException
- Thrown if not numericpublic void allocate(int additional)
allocate
in interface ValueGenerator
additional
- The number to allocateprotected ValueGenerationBlock obtainGenerationBlock()
protected ValueGenerationBlock obtainGenerationBlock(int number)
number
- The number of additional ids requiredprotected ValueGenerationBlock reserveBlock()
protected abstract ValueGenerationBlock reserveBlock(long size)
size
- Number of values to reserveprotected boolean requiresRepository()
protected boolean repositoryExists()
protected boolean createRepository()
Copyright © 2021. All rights reserved.