Class RND

java.lang.Object
kz.greetgo.util.RND

public class RND extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final char[]
     
    static final String
     
    static final char[]
     
    static final String
     
    static final String
     
    static final String
     
    static final Random
     
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RND()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static BigDecimal
    bd(long max, int afterPoint)
    Generates a random number of type BigDecimal in the range
    static boolean
    Generates random Boolean value
    static byte[]
    byteArray(int len)
    Generates a random array with a length len
    static Date
    dateDays(int fromDaysBeforeNow, int toDayAfterNow)
    Generates a random date in the range from fromDaysBeforeNow days ago, to toDayAfterNow days ago
    static 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(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 Enum<E>>
    E
    someEnum(E... values)
    Selects a random value from the values transmitted from enum
    static String
    str(int len)
    Generates random string with a length of len characters.
    static String
    strEng(int len)
    Generates random string with a length of len characters.
    static String
    strFrom(int len, char[] availableChars)
    Generates random string with a length of len characters.
    static 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 Details

  • Constructor Details

    • RND

      public RND()
  • Method Details

    • str

      public static 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 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 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 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 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 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 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(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 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