Class RandomProviderImpl

java.lang.Object
org.instancio.internal.random.RandomProviderImpl
All Implemented Interfaces:
RandomProvider

public class RandomProviderImpl extends Object implements RandomProvider
  • Constructor Details

    • RandomProviderImpl

      public RandomProviderImpl()
      Create an instance with a random seed value.
    • RandomProviderImpl

      public RandomProviderImpl(int seed)
      Create an instance with the given seed value.
      Parameters:
      seed - for the random generator
  • Method Details

    • getSeed

      public int getSeed()
      Description copied from interface: RandomProvider
      Returns the seed value used by the random number generator.
      Specified by:
      getSeed in interface RandomProvider
      Returns:
      seed value
    • trueOrFalse

      public boolean trueOrFalse()
      Specified by:
      trueOrFalse in interface RandomProvider
      Returns:
      a random true or false value with a 0.5 probability.
    • diceRoll

      public boolean diceRoll(boolean precondition)
      Specified by:
      diceRoll in interface RandomProvider
      Parameters:
      precondition - required for returning true value
      Returns:
      a random true with 1/6 probability.
    • byteBetween

      public byte byteBetween(byte min, byte max)
      Specified by:
      byteBetween in interface RandomProvider
      Parameters:
      min - lower bound
      max - upper bound (exclusive)
      Returns:
      a random byte between the min and max, exclusive
    • shortBetween

      public short shortBetween(short min, short max)
      Specified by:
      shortBetween in interface RandomProvider
      Parameters:
      min - lower bound
      max - upper bound (exclusive)
      Returns:
      a random short between the min and max, exclusive
    • intBetween

      public int intBetween(int min, int max)
      Specified by:
      intBetween in interface RandomProvider
      Parameters:
      min - lower bound
      max - upper bound (exclusive)
      Returns:
      a random int between the min and max, exclusive
    • longBetween

      public long longBetween(long min, long max)
      Specified by:
      longBetween in interface RandomProvider
      Parameters:
      min - lower bound
      max - upper bound (exclusive)
      Returns:
      a random long between the min and max, exclusive
    • floatBetween

      public float floatBetween(float min, float max)
      Specified by:
      floatBetween in interface RandomProvider
      Parameters:
      min - lower bound
      max - upper bound (exclusive)
      Returns:
      a random float between the min and max, exclusive
    • doubleBetween

      public double doubleBetween(double min, double max)
      Specified by:
      doubleBetween in interface RandomProvider
      Parameters:
      min - lower bound
      max - upper bound (exclusive)
      Returns:
      a random double between the min and max, exclusive
    • character

      public char character()
      Specified by:
      character in interface RandomProvider
      Returns:
      random uppercase character between A-Z inclusive.
    • alphabetic

      public String alphabetic(int length)
      Specified by:
      alphabetic in interface RandomProvider
      Parameters:
      length - of the string to generate
      Returns:
      random uppercase String with given length
    • from

      public <T> T from(T[] array)
      Description copied from interface: RandomProvider
      Returns a random element from given array.
      Specified by:
      from in interface RandomProvider
      Type Parameters:
      T - element type
      Parameters:
      array - to pick a value from
      Returns:
      random element
    • from

      public <T> T from(Collection<T> collection)
      Description copied from interface: RandomProvider
      Returns a random element from given collection.
      Specified by:
      from in interface RandomProvider
      Type Parameters:
      T - element type
      Parameters:
      collection - to pick a value from
      Returns:
      random element