java.lang.Object | ||
↳ | org.apache.commons.betwixt.io.id.AbstractIDGenerator | |
↳ | org.apache.commons.betwixt.io.id.RandomIDGenerator |
Generates ID
's at random.
The random number source is java.util.Random
.
Random ID
's are very useful if you're inserting
elements created by Betwixt
into a stream with existing
elements.
Using random ID
's should reduce the danger of collision
with existing element ID
's.
This class can generate positive-only ids (the default)
or it can generate a mix of negative and postive ones.
This behaviour can be set by setPositiveIds(boolean)
or by using the RandomIDGenerator(boolean)
constructor.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor sets the
PositiveIds property to true . | |||||||||||
Constructor sets
PositiveIds property. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets whether only positive
ID 's should be generated | |||||||||||
Generates a random | |||||||||||
Sets whether only positive
ID 's should be generated |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.betwixt.io.id.AbstractIDGenerator
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.apache.commons.betwixt.io.IDGenerator
|
Constructor sets the PositiveIds
property to true
.
Constructor sets PositiveIds
property.
onlyPositiveIds | set PositiveIds property to this value
|
---|
Gets whether only positive ID
's should be generated
Generates a random ID
.
If the PositiveIds
property is true,
then this method will recursively call itself if the random
ID
is less than zero.
Sets whether only positive ID
's should be generated
onlyPositiveIds | pass true if only positive IDs should be generated |
---|