Class RND


  • public class RND
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ALL  
      static char[] ALL_CHARS  
      static java.lang.String ALL_ENG  
      static char[] ALL_ENG_CHARS  
      static java.lang.String DEG  
      static java.lang.String eng  
      static java.lang.String ENG  
      static java.util.Random rnd  
      static java.lang.String rus  
      static java.lang.String RUS  
    • Constructor Summary

      Constructors 
      Constructor Description
      RND()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.math.BigDecimal bd​(long max, int afterPoint)
      Generates a random number of type BigDecimal in the range
      static boolean bool()
      Generates random Boolean value
      static byte[] byteArray​(int len)
      Generates a random array with a length len
      static java.util.Date dateDays​(int fromDaysBeforeNow, int toDayAfterNow)
      Generates a random date in the range from fromDaysBeforeNow days ago, to toDayAfterNow days ago
      static java.util.Date dateYears​(int yearFrom, int yearTo)
      Generates a random date in the range from yearFrom years ago, to yearTo years ago
      static <T> T from​(T... values)
      Selects random element from varargs array
      static <T> T of​(java.util.Collection<T> source)
      Selects random element from list
      static double plusDouble​(double max, int point)
      Generates a random real positive number in the range
      static int plusInt​(int max)
      Generates a random positive number of type int in the range
      static long plusLong​(long max)
      Generates a random positive number of type long in the range
      static <E extends java.lang.Enum<E>>
      E
      someEnum​(E... values)
      Selects a random value from the values transmitted from enum
      static java.lang.String str​(int len)
      Generates random string with a length of len characters.
      static java.lang.String strEng​(int len)
      Generates random string with a length of len characters.
      static java.lang.String strFrom​(int len, char[] availableChars)
      Generates random string with a length of len characters.
      static java.lang.String strInt​(int len)
      Generates a string consisting of random numbers
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RUS

        public static final java.lang.String RUS
      • ENG

        public static final java.lang.String ENG
      • ALL

        public static final java.lang.String ALL
      • ALL_CHARS

        public static final char[] ALL_CHARS
      • ALL_ENG

        public static final java.lang.String ALL_ENG
      • ALL_ENG_CHARS

        public static final char[] ALL_ENG_CHARS
      • rnd

        public static final java.util.Random rnd
    • Constructor Detail

      • RND

        public RND()
    • Method Detail

      • str

        public static java.lang.String str​(int len)
        Generates random string with a length of len characters. 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

        public static java.lang.String strEng​(int len)
        Generates random string with a length of len characters. 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

        public static java.lang.String strFrom​(int len,
                                               char[] availableChars)
        Generates random string with a length of len characters. Characters are selected randomly from the array availableChars
        Parameters:
        len - the length of generate string
        availableChars - the source of characters for generation string.
        Returns:
        generated string
      • strInt

        public static java.lang.String strInt​(int len)
        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 long in the range

        0 <= 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 int in the range

        0 <= x < max

        Parameters:
        max - the maximum value of the generate number
        Returns:
        generated number
      • dateYears

        public static java.util.Date dateYears​(int yearFrom,
                                               int yearTo)
        Generates a random date in the range from yearFrom years ago, to yearTo years ago
        Parameters:
        yearFrom - as many years ago - range start in which date is generated
        yearTo - as many years ago - range end in which date is generated
        Returns:
        randomly generated date
      • dateDays

        public static java.util.Date dateDays​(int fromDaysBeforeNow,
                                              int toDayAfterNow)
        Generates a random date in the range from fromDaysBeforeNow days ago, to toDayAfterNow days ago
        Parameters:
        fromDaysBeforeNow - as many days ago - range start in which date is generated
        toDayAfterNow - 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 length len
        Parameters:
        len - the length of generate array
        Returns:
        generated array
      • bool

        public static boolean bool()
        Generates random Boolean value
        Returns:
        generated random value
      • someEnum

        @SafeVarargs
        public static <E extends java.lang.Enum<E>> E someEnum​(E... values)
        Selects a random value from the values transmitted from enum
        Parameters:
        values - enum values
        Returns:
        randomly selected value
      • from

        @SafeVarargs
        public static <T> T from​(T... values)
        Selects random element from varargs array
        Type Parameters:
        T - any returning type
        Parameters:
        values - varargs source array
        Returns:
        random element from the array
      • of

        public static <T> T of​(java.util.Collection<T> source)
        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 values
        point - the number of decimal places
        Returns:
        generated number
      • bd

        public static java.math.BigDecimal bd​(long max,
                                              int afterPoint)

        Generates a random number of type BigDecimal in the range

        0 <= x < max

        Parameters:
        max - the upper limit of generate number
        afterPoint - the number of decimal places
        Returns:
        generated number