Packages

trait ThreadLocalRandom extends AnyRef

A collection of useful functions to generate random values for all types Utilizes Java's ThreadLocalRandom rather than the Regular Random

Per my current understanding while the regular Java random functions is thread safe If used concurrently the regular random could contention and thus performance loss Using ThreadLocalRandom's implementation of random solves that problem

Since

2.12

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ThreadLocalRandom
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def getRandomAlpha(maxLength: Int, minLength: Int = 0): String

    Returns a string of pseudorandom lower and upper case letters from the current thread local random instance.

    Returns a string of pseudorandom lower and upper case letters from the current thread local random instance.

    maxLength

    The greatest number of char the random string the return can possibly be (inclusive)

    minLength

    The least number of char the random string will be; defaults to max value

    returns

    A pseudorandom Letters only string

  11. def getRandomAlphaNumeric(maxLength: Int, minLength: Int = 0): String

    Returns a string of pseudorandom numbers and lower/upper case letters from the current thread local random instance.

    Returns a string of pseudorandom numbers and lower/upper case letters from the current thread local random instance.

    maxLength

    The greatest number of char the random string the return can possibly be (inclusive)

    minLength

    The least number of char the random string will be; defaults to max value

    returns

    A pseudorandom Letters and Numbers string

  12. def getRandomCustom(maxLength: Int, minLength: Int, chars: Seq[Char]): String

    Returns a string of pseudorandom user defined input from the current thread local random instance.

    Returns a string of pseudorandom user defined input from the current thread local random instance.

    This is the work horse of the entire Random String set of functions as they are all just hard coded user defined char sets It is also where the random length of the string is determined for all of them

    maxLength

    The greatest number of char the random string the return can possibly be

    minLength

    The least number of char the random string will be; defaults to max value

    chars

    The seq of character's you wish to choose from to form this string

    returns

    A pseudorandom string from user defined values

  13. def getRandomDouble(max: Double = Double.MaxValue, min: Double = 1.0): Double

    Returns the next generated pseudorandom between Double.MaxValue and Double.MinValue from the current thread local random instance.

    Returns the next generated pseudorandom between Double.MaxValue and Double.MinValue from the current thread local random instance.

    max

    The greatest Double the return can possibly be (inclusive)

    min

    The least Double the return can possibly be (inclusive)

    returns

    A pseudorandom Double

    Note

    Within the java implementation of ThreadLocalRandom The origin (min) is inclusive The bound (max) is exclusive Have to do a little math on the decimal point to determine how much you need to add in order to make the max value inclusive We don't need to add 1 to the double that are valid Int's because a max of 1 min of 0 would result in a possible value of 1.1

  14. def getRandomDoubleFormatted(max: Double = Double.MaxValue, min: Double = 1.0, decimalPlaces: Int = 2): String

    Returns the next generated pseudorandom Double between user defined max and user defined min from the current thread local random instance with specific amount of decimal places.

    Returns the next generated pseudorandom Double between user defined max and user defined min from the current thread local random instance with specific amount of decimal places.

    max

    The greatest Double the return can possibly be (inclusive)

    min

    The least Double the return can possibly be (inclusive)

    decimalPlaces

    The amount of decimal places in the returned value

    returns

    A pseudorandom Double

  15. def getRandomFloat(max: Float = Float.MaxValue, min: Float = 1.0F): Float

    Returns the next generated pseudorandom between Float.MaxValue and Float.MinValue from the current thread local random instance.

    Returns the next generated pseudorandom between Float.MaxValue and Float.MinValue from the current thread local random instance.

    max

    The greatest Float the return can possibly be (inclusive)

    min

    The least Float the return can possibly be (inclusive)

    returns

    A pseudorandom Float

    Note

    Within the java implementation of ThreadLocalRandom The origin (min) is inclusive The bound (max) is exclusive Have to do a little math on the decimal point to determine how much you need to add in order to make the max value inclusive We don't need to add 1 to the double that are valid Int's because a max of 1 min of 0 would result in a possible value of 1.1

  16. def getRandomInt(max: Int = Int.MaxValue, min: Int = 1): Int

    Returns the next generated pseudorandom between Int.MaxValue and Int.MinValue from the current thread local random instance.

    Returns the next generated pseudorandom between Int.MaxValue and Int.MinValue from the current thread local random instance.

    max

    The greatest Int the return can possibly be (inclusive)

    min

    The least Int the return can possibly be (inclusive)

    returns

    A pseudorandom Int

    Note

    Within the java implementation of ThreadLocalRandom The origin (min) is inclusive The bound (max) is exclusive Which is why its necessary to sometimes add 1 behind the scenes to the max value so this becomes inclusive

  17. def getRandomLong(max: Long = Long.MaxValue, min: Long = 1L): Long

    Returns the next generated pseudorandom between Long.MaxValue and Long.MinValue from the current thread local random instance.

    Returns the next generated pseudorandom between Long.MaxValue and Long.MinValue from the current thread local random instance.

    max

    The greatest Long the return can possibly be (inclusive)

    min

    The least Long the return can possibly be (inclusive)

    returns

    A pseudorandom Long

    Note

    Within the java implementation of ThreadLocalRandom The origin (min) is inclusive The bound (max) is exclusive Which is why its necessary to sometimes add 1 behind the scenes to the max value so this becomes inclusive

  18. def getRandomNumeric(maxLength: Int, minLength: Int = 0): String

    Returns a string of pseudorandom numbers from the current thread local random instance.

    Returns a string of pseudorandom numbers from the current thread local random instance.

    maxLength

    The greatest number of char the random string the return can possibly be

    minLength

    The least number of char the random string will be; defaults to max value

    returns

    A pseudorandom Letters and Numbers string

  19. def getRandomZonedDateTime(alphaDateTime: ZonedDateTime, omegaDateTime: ZonedDateTime, zoneId: Option[String] = None): ZonedDateTime

    Returns the next generated pseudorandom Date and Time

    Returns the next generated pseudorandom Date and Time

    alphaDateTime

    The most distant a timestamp should be for the time range

    omegaDateTime

    The least distant a timestamp should be for the time range

    zoneId

    The timezone

    returns

    A pseudorandom ZonedDateTime

  20. def getRandomZonedDateTime(alphaDateTime: ZonedDateTime, omegaDateTime: ZonedDateTime, dateTimeFormat: String, zoneId: Option[String]): String

    Returns the next generated pseudorandom Date and Time

    Returns the next generated pseudorandom Date and Time

    alphaDateTime

    The most distant a timestamp should be for the time range

    omegaDateTime

    The least distant a timestamp should be for the time range

    dateTimeFormat

    The format the date and time should be in

    zoneId

    The timezone

    returns

    A pseudorandom Formatted String of ZonedDateTime

  21. def getRandomZonedDateTimeByOffset(pastOffsetInSeconds: Long, futureOffsetInSeconds: Long, mediumDateTime: ZonedDateTime): ZonedDateTime

    Returns the next generated pseudorandom Date and Time

    Returns the next generated pseudorandom Date and Time

    pastOffsetInSeconds

    The most distant a datetime should in seconds to be considered for the time range

    futureOffsetInSeconds

    The least distant a datetime should in seconds to be considered for the time range

    mediumDateTime

    The middle of the datetime range

    returns

    A pseudorandom ZonedDateTime

  22. def getRandomZonedDateTimeByOffset(dateTimeFormat: String, pastOffsetInSeconds: Long, futureOffsetInSeconds: Long, mediumDateTime: ZonedDateTime): String

    Returns the next generated pseudorandom Date and Time

    Returns the next generated pseudorandom Date and Time

    dateTimeFormat

    The format of the returned datetime

    pastOffsetInSeconds

    The most distant a datetime should in seconds to be considered for the time range

    futureOffsetInSeconds

    The least distant a datetime should in seconds to be considered for the time range

    mediumDateTime

    The middle of the datetime range

    returns

    A pseudorandom Formatted String of ZonedDateTime

  23. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  27. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  28. def setRandomSeed(seed: Long): Unit

    Sets the random seed for every ThreadLocalRandom call

    Sets the random seed for every ThreadLocalRandom call

    seed

    The value to use to seed the ThreadLocalRandom calls

    returns

    Unit

  29. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  30. def toString(): String
    Definition Classes
    AnyRef → Any
  31. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped