public class CodeGeneratorBucket extends Object
| Modifier and Type | Field and Description |
|---|---|
protected int |
bucketIterationNumber |
protected long |
bucketPrefixCodePopulation |
protected int |
bucketsNeeded |
protected int |
charsNeededForEachBucket |
protected CodeFormatAvailableCharHelper |
helper |
protected int |
totalCharsInFormatForBucket |
| Constructor and Description |
|---|
CodeGeneratorBucket(CodeFormatAvailableCharHelper helper,
int totalCodesNeeded,
String codeFormat,
int batchSize) |
| Modifier and Type | Method and Description |
|---|---|
long |
calculateBucketPrefixNumber(Random r)
Calculates an integer representation of this bucket.
|
protected void |
computeBaseDivisors(String codeFormat)
The base divisors are used to effectively determine the "base" of each character in the code.
|
protected int |
determineNumberOfCharsNeededForBuckets(String codeFormat,
CodeFormatAvailableCharHelper helper)
Returns the number of buckets of "batch size" needed to produce unique
|
int |
getBucketIterationNumber()
Starts at one and is incremented each time a new bucket of codes has been generated.
|
long |
getBucketPrefixCodePopulation()
Number of codes available in a given bucket.
|
int |
getBucketsNeeded() |
int |
getCharsNeededForEachBucket() |
void |
setBucketPrefixCodePopulation(long bucketPrefixCodePopulation) |
void |
setBucketsNeeded(int bucketsNeeded) |
void |
setCharsNeededForEachBucket(int charsNeededForEachBucket) |
void |
updateBucketIteration() |
String |
updateCodeFormatWithBucketPrefix(String codeFormat,
Random r)
Returns the passed in code after substituting the first "charNeededForEachBucket"
in the code format with the appropriate bucket prefix.
|
protected int bucketIterationNumber
protected int bucketsNeeded
protected int charsNeededForEachBucket
protected int totalCharsInFormatForBucket
protected long bucketPrefixCodePopulation
protected CodeFormatAvailableCharHelper helper
public CodeGeneratorBucket(CodeFormatAvailableCharHelper helper, int totalCodesNeeded, String codeFormat, int batchSize)
protected void computeBaseDivisors(String codeFormat)
codeFormat - public String updateCodeFormatWithBucketPrefix(String codeFormat, Random r)
codeFormat - r - public long calculateBucketPrefixNumber(Random r)
getBucketPrefixCodePopulation() size of
10 and you also needed 10 buckets needed, then this method would return the bucketIterationNumber.
Otherwise, it segments the bucketPopulation and returns a random value that is valid for the range
of the current segment.public int getBucketIterationNumber()
public int getBucketsNeeded()
public void setBucketsNeeded(int bucketsNeeded)
bucketsNeeded - getBucketsNeeded()public int getCharsNeededForEachBucket()
public void setCharsNeededForEachBucket(int charsNeededForEachBucket)
charsNeededForEachBucket - getCharsNeededForEachBucket()public long getBucketPrefixCodePopulation()
public void setBucketPrefixCodePopulation(long bucketPrefixCodePopulation)
bucketPrefixCodePopulation - getBucketPrefixCodePopulation()public void updateBucketIteration()
protected int determineNumberOfCharsNeededForBuckets(String codeFormat, CodeFormatAvailableCharHelper helper)
formatElement - Copyright © 2020. All rights reserved.