Package kz.greetgo.util
Class RND
java.lang.Object
kz.greetgo.util.RND
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimalbd(long max, int afterPoint) Generates a random number of typeBigDecimalin the rangestatic booleanbool()Generates random Boolean valuestatic byte[]byteArray(int len) Generates a random array with a lengthlenstatic DatedateDays(int fromDaysBeforeNow, int toDayAfterNow) Generates a random date in the range fromfromDaysBeforeNowdays ago, totoDayAfterNowdays agostatic DatedateYears(int yearFrom, int yearTo) Generates a random date in the range fromyearFromyears ago, toyearToyears agostatic <T> Tfrom(T... values) Selects random element from varargs arraystatic <T> Tof(Collection<T> source) Selects random element from liststatic doubleplusDouble(double max, int point) Generates a random real positive number in the rangestatic intplusInt(int max) Generates a random positive number of typeintin the rangestatic longplusLong(long max) Generates a random positive number of typelongin the rangestatic <E extends Enum<E>>
EsomeEnum(E... values) Selects a random value from the values transmitted from enumstatic Stringstr(int len) Generates random string with a length oflencharacters.static StringstrEng(int len) Generates random string with a length oflencharacters.static StringstrFrom(int len, char[] availableChars) Generates random string with a length oflencharacters.static StringstrInt(int len) Generates a string consisting of random numbers
-
Field Details
-
rus
- See Also:
-
RUS
-
eng
- See Also:
-
ENG
-
DEG
- See Also:
-
ALL
-
ALL_CHARS
public static final char[] ALL_CHARS -
ALL_ENG
-
ALL_ENG_CHARS
public static final char[] ALL_ENG_CHARS -
rnd
-
-
Constructor Details
-
RND
public RND()
-
-
Method Details
-
str
Generates random string with a length oflencharacters. Characters are selected randomly from the following array: Arabic numerals, Russian alphabet uppercase and lowercase, English alphabet uppercase and lowercase.- Parameters:
len- the length of generate string- Returns:
- generated string
-
strEng
Generates random string with a length oflencharacters. Characters are selected randomly from the following array: Arabic numerals, English alphabet uppercase and lowercase.- Parameters:
len- the length of generate string- Returns:
- generated string
-
strFrom
Generates random string with a length oflencharacters. Characters are selected randomly from the arrayavailableChars- Parameters:
len- the length of generate stringavailableChars- the source of characters for generation string.- Returns:
- generated string
-
strInt
Generates a string consisting of random numbers- Parameters:
len- the length of generate string- Returns:
- generated string
-
plusLong
public static long plusLong(long max) Generates a random positive number of type
longin the range0 <= x < max
- Parameters:
max- the maximum value of the generate number- Returns:
- generated number
-
plusInt
public static int plusInt(int max) Generates a random positive number of type
intin the range0 <= x < max
- Parameters:
max- the maximum value of the generate number- Returns:
- generated number
-
dateYears
Generates a random date in the range fromyearFromyears ago, toyearToyears ago- Parameters:
yearFrom- as many years ago - range start in which date is generatedyearTo- as many years ago - range end in which date is generated- Returns:
- randomly generated date
-
dateDays
Generates a random date in the range fromfromDaysBeforeNowdays ago, totoDayAfterNowdays ago- Parameters:
fromDaysBeforeNow- as many days ago - range start in which date is generatedtoDayAfterNow- as many days ago - range end in which date is generated- Returns:
- randomly generated date
-
byteArray
public static byte[] byteArray(int len) Generates a random array with a lengthlen- Parameters:
len- the length of generate array- Returns:
- generated array
-
bool
public static boolean bool()Generates random Boolean value- Returns:
- generated random value
-
someEnum
Selects a random value from the values transmitted from enum- Parameters:
values- enum values- Returns:
- randomly selected value
-
from
Selects random element from varargs array- Type Parameters:
T- any returning type- Parameters:
values- varargs source array- Returns:
- random element from the array
-
of
Selects random element from list- Type Parameters:
T- any returning type- Parameters:
source- source list- Returns:
- random element from the list
-
plusDouble
public static double plusDouble(double max, int point) Generates a random real positive number in the range
0 <= x < max
- Parameters:
max- the upper limit of the selected valuespoint- the number of decimal places- Returns:
- generated number
-
bd
Generates a random number of type
BigDecimalin the range0 <= x < max
- Parameters:
max- the upper limit of generate numberafterPoint- the number of decimal places- Returns:
- generated number
-