public class RandomGenerator<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_DELIMITER
Default Delimiter is equal to three tilde (~~~) characters.
|
static java.lang.String |
RATING
If the List object includes an Integer field called "rating", this value can be used to
provide additional weighting to the randomization.
|
static int |
RATING_LEVEL_HIGH
When using randomize() methods which include the int ratingLevel,
the RATING_LEVEL_HIGH enables the most aggressive preference toward
selecting higher rated items.
|
static int |
RATING_LEVEL_LOW
When using randomize() methods which include the int ratingLevel,
the RATING_LEVEL_LOW enables the lowest form of weighting for the list
items being randomized.
|
static int |
RATING_LEVEL_MEDIUM
When using randomize() methods which include the int ratingLevel,
the RATING_LEVEL_MEDIUM enables a more aggressive preference toward
selecting higher rated items.
|
static int |
RATING_LEVEL_OFF
When using randomize() methods which include the int ratingLevel,
the RATING_LEVEL_OFF disables the rating functionality.
|
Constructor and Description |
---|
RandomGenerator() |
Modifier and Type | Method and Description |
---|---|
java.util.List<T> |
randomize(java.util.List<T> tList)
Randomizes the elements in a given tList and returns a new
List object of the same type.
|
java.util.List<T> |
randomize(java.util.List<T> tList,
java.lang.Boolean useRating)
Randomizes the elements in a given tList (which contains a field
named "rating"), applies weighting based upon the rating (if enabled),
and returns a new List object of the same type.
|
java.util.List<T> |
randomize(java.util.List<T> tList,
int ratingLevel)
Randomizes the elements in a given tList (which contains a field
named "rating"), applies weighting based upon the rating (if enabled),
and returns a new List object of the same type.
|
java.util.List<T> |
randomize(java.util.List<T> tList,
java.lang.Integer maxResults)
Randomizes the elements in a given tList and returns a new
List object of the same type, limited to the number provided in
the maxResults object.
|
java.util.List<T> |
randomize(java.util.List<T> tList,
java.lang.Integer maxResults,
java.lang.Boolean useRating)
Randomizes the elements in a given tList (which contains a field
named "rating"), applies weighting based upon the rating (if enabled),
and returns a new List object of the same type - limited to the number
provided in the maxResults object.
|
java.util.List<T> |
randomize(java.util.List<T> tList,
java.lang.Integer maxResults,
int ratingLevel)
Randomizes the elements in a given tList (which contains a field
named "rating"), applies weighting based upon the rating (if enabled),
and returns a new List object of the same type.
|
java.lang.String |
randomize(java.lang.String thisString,
java.lang.String thisSeparator)
For a given thisString object that contains multiple elements denoted
by a thisString separator, a new String will be returned, randomizing
the values from the source String object.
|
java.lang.String |
randomize(java.lang.String thisString,
java.lang.String thisSeparator,
java.lang.Integer maxResults)
For a given thisString object that contains multiple elements denoted
by a thisString separator, a new String will be returned, randomizing
the values from the source String object, limited to the number provided in
the maxResults object.
|
public static java.lang.String DEFAULT_DELIMITER
Default Delimiter is equal to three tilde (~~~) characters. This is the assumed default delimiter when a delimiter is not specified.
public static java.lang.String RATING
If the List object includes an Integer field called "rating", this value can be used to provide additional weighting to the randomization.
Consider the following two items in the list:
When using rating in the randomization in the example above, the Orange object will have a greater number of chances than the Apple object has to be selected. The feature allows certain value to have a greater chance to be selected.
A rating scale of 1 to 5 is recommended, but since version 1.3 this is no longer a requirement.
public static final int RATING_LEVEL_OFF
When using randomize() methods which include the int ratingLevel, the RATING_LEVEL_OFF disables the rating functionality. This is the same providing a false value to the legacy randomize() methods which included a useRating Boolean object in the signature.
public static final int RATING_LEVEL_LOW
When using randomize() methods which include the int ratingLevel, the RATING_LEVEL_LOW enables the lowest form of weighting for the list items being randomized.
Usage of the randomize() methods which include the useRating Boolean set to true will utilize this rating level during the randomization process.
This is similar to the original weighting that was provided with versions 1.2 and earlier of RandomGenerator and follows a 1 to 5 ratio from lowest to highest rated items.
public static final int RATING_LEVEL_MEDIUM
When using randomize() methods which include the int ratingLevel, the RATING_LEVEL_MEDIUM enables a more aggressive preference toward selecting higher rated items.
When compared to RATING_LEVEL_LOW, there is a four times greater emphasis on higher weighted items over lower weighted items at the most extreme difference in rating scale.
Please note - when using randomize() methods which include the Boolean useRating object, the RATING_LEVEL_LOW level of weighting will be utilized, as this is the default rating level.
public static final int RATING_LEVEL_HIGH
When using randomize() methods which include the int ratingLevel, the RATING_LEVEL_HIGH enables the most aggressive preference toward selecting higher rated items.
When compared to RATING_LEVEL_LOW, there is a forty times greater emphasis on higher weighted items over lower weighted items at the most extreme difference in rating scale.
public java.util.List<T> randomize(java.util.List<T> tList)
tList
- List object to randomizepublic java.util.List<T> randomize(java.util.List<T> tList, java.lang.Boolean useRating)
Randomizes the elements in a given tList (which contains a field named "rating"), applies weighting based upon the rating (if enabled), and returns a new List object of the same type. All items in the original tList will be returned.
If the useRating Boolean is set to true, the randomization will be weighted to favor those with a higher rating field value using the level of weighting provided with the RATING_LEVEL_LOW value.
If other RATING_LEVEL_* levels are required, please use a randomize() method which includes the int ratingLevel object.
tList
- List object to randomizeuseRating
- Boolean to indicate if rating field will be usedpublic java.util.List<T> randomize(java.util.List<T> tList, int ratingLevel)
Randomizes the elements in a given tList (which contains a field named "rating"), applies weighting based upon the rating (if enabled), and returns a new List object of the same type. All items in the original tList will be returned.
If the ratingLevel is equal to RATING_LEVEL_OFF, the rating processing will be ignored. Otherwise, the RATING_LEVEL_* value will determine the weighting for higher ranked items.
For additional information for each RATING_LEVEL_* value, please review the documentation for each level.
tList
- the List
to randomizeratingLevel
- the ratingLevel to utilizeList
public java.util.List<T> randomize(java.util.List<T> tList, java.lang.Integer maxResults)
Randomizes the elements in a given tList and returns a new List object of the same type, limited to the number provided in the maxResults object. Passing a maxResults value of zero will return a List object of the same size as the original tList object.
If the maxResults value is greater than the tList size, the return List object will match the size of the original tList.
tList
- List object to randomizemaxResults
- the size of the return List (specify 0 to return all results)public java.util.List<T> randomize(java.util.List<T> tList, java.lang.Integer maxResults, java.lang.Boolean useRating)
Randomizes the elements in a given tList (which contains a field named "rating"), applies weighting based upon the rating (if enabled), and returns a new List object of the same type - limited to the number provided in the maxResults object. Passing a maxResults value of zero will return a List object of the same size as the original tList object.
If the maxResults value is greater than the tList size, the return List object will match the size of the original tList.
If the useRating Boolean is set to true, the randomization will be weighted to favor those with a higher rating field value using the level of weighting provided with the RATING_LEVEL_LOW value.
If other RATING_LEVEL_* levels are required, please use a randomize() method which includes the int ratingLevel object.
tList
- List object to randomizemaxResults
- the size of the return List (specify 0 to return all results)useRating
- Boolean to indicate if rating field will be usedpublic java.util.List<T> randomize(java.util.List<T> tList, java.lang.Integer maxResults, int ratingLevel)
Randomizes the elements in a given tList (which contains a field named "rating"), applies weighting based upon the rating (if enabled), and returns a new List object of the same type. All items in the original tList will be returned.
If the ratingLevel is equal to RATING_LEVEL_OFF, the rating processing will be ignored. Otherwise, the RATING_LEVEL_* value will determine the weighting for higher ranked items.
For additional information for each RATING_LEVEL_* value, please review the documentation for each level.
tList
- List object to randomizemaxResults
- the size of the return List (specify 0 to return all results)ratingLevel
- int to indicate the level of RATING_WEIGHT to applypublic java.lang.String randomize(java.lang.String thisString, java.lang.String thisSeparator)
thisString
- String object to randomizethisSeparator
- String value of separator for thisString objectpublic java.lang.String randomize(java.lang.String thisString, java.lang.String thisSeparator, java.lang.Integer maxResults)
For a given thisString object that contains multiple elements denoted by a thisString separator, a new String will be returned, randomizing the values from the source String object, limited to the number provided in the maxResults object. Passing a maxResults value of zero will return a String object of the same size as the original String object.
If the maxResults value is greater than the number of elements within the thisString object, the return String object will match the size of the original thisString.
thisString
- String object to randomizethisSeparator
- String value of separator for thisString objectmaxResults
- the size of the return String (specify 0 to return all results)