Class RandomProvider


  • public class RandomProvider
    extends Object
    • Constructor Detail

      • RandomProvider

        public RandomProvider​(int seed)
        Create an instance with a seed value.
        Parameters:
        seed - for the random generator
      • RandomProvider

        public RandomProvider()
        Create an instance with a random seed value.
    • Method Detail

      • getSeed

        public int getSeed()
      • trueOrFalse

        public boolean trueOrFalse()
        Returns:
        a random true or false value with a 0.5 probability.
      • diceRoll

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

        public byte byteBetween​(byte min,
                                byte max)
        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)
        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)
        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)
        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)
        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)
        Parameters:
        min - lower bound
        max - upper bound (exclusive)
        Returns:
        a random double between the min and max, exclusive
      • character

        public char character()
        Returns:
        random uppercase character between A-Z inclusive.
      • alphabetic

        public String alphabetic​(int length)
        Parameters:
        length - of the string to generate
        Returns:
        random uppercase String with given length
      • from

        public <T> T from​(T[] array)
      • from

        public <T> T from​(Collection<T> collection)