Class RandomProviderImpl

    • Constructor Detail

      • 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 Detail

      • 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.
      • byteRange

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

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

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

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

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

        public double doubleRange​(double min,
                                  double max)
        Specified by:
        doubleRange 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()
        Description copied from interface: RandomProvider
        Returns a random alphabetic character, [a-z, A-Z].
        Specified by:
        character in interface RandomProvider
        Returns:
        random character, either lower or upper case
      • lowerCaseCharacter

        public char lowerCaseCharacter()
        Description copied from interface: RandomProvider
        Returns a random lower alphabetic character, [a-z].
        Specified by:
        lowerCaseCharacter in interface RandomProvider
        Returns:
        random lower character
      • upperCaseCharacter

        public char upperCaseCharacter()
        Description copied from interface: RandomProvider
        Returns a random upper alphabetic character, [A-Z].
        Specified by:
        upperCaseCharacter in interface RandomProvider
        Returns:
        random uppercase character
      • lowerCaseAlphabetic

        public String lowerCaseAlphabetic​(int length)
        Description copied from interface: RandomProvider
        Generates a lower case String comprised of [a-z].
        Specified by:
        lowerCaseAlphabetic in interface RandomProvider
        Parameters:
        length - of a string to generate
        Returns:
        random lower case String with given length
      • upperCaseAlphabetic

        public String upperCaseAlphabetic​(int length)
        Description copied from interface: RandomProvider
        Generates a random upper case String comprised of [A-Z].
        Specified by:
        upperCaseAlphabetic in interface RandomProvider
        Parameters:
        length - of a string to generate
        Returns:
        random upper case String with given length
      • digits

        public String digits​(int length)
        Description copied from interface: RandomProvider
        Generates a random String comprised of digits [0-9].
        Specified by:
        digits in interface RandomProvider
        Parameters:
        length - of a string to generate
        Returns:
        random String comprised of digits with given length
      • alphaNumeric

        public String alphaNumeric​(int length)
        Description copied from interface: RandomProvider
        Generates a random alphanumeric String comprised of [a-z, A-Z, 0-9].
        Specified by:
        alphaNumeric in interface RandomProvider
        Parameters:
        length - of a string to generate
        Returns:
        random alphanumeric String with given length
      • mixedCaseAlphabetic

        public String mixedCaseAlphabetic​(int length)
        Description copied from interface: RandomProvider
        Generates a random mixed case String comprised of [a-z, A-Z].
        Specified by:
        mixedCaseAlphabetic in interface RandomProvider
        Parameters:
        length - of a string to generate
        Returns:
        random mixed case String with given length
      • oneOf

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

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