Interface Generator

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Generator
A utility interface: represents an interface of a basic arbitrary generator that defines methods for primitive values as well as values of some other basic types, including enum types, String and BigInteger.

Most methods provide a default implementation that (directly or indirectly) uses anyBits(int). The latter is the only method without a default implementation.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default BigInteger
    Returns a BigInteger value between Long.MIN_VALUE and Long.MAX_VALUE (both incl.).
    default BigInteger
    Returns a BigInteger value between BigInteger.ZERO (incl.) and bound (excl.).
    default BigInteger
    Returns a BigInteger value between min (incl.) and bound (excl.).
    anyBits(int numBits)
    Returns any non-negative BigInteger representing a sequence of significant bits of a given length.
    static BigInteger
    anyBits(int numBits, Random random)
    Utility method: Returns a randomly generated non-negative BigInteger representing a sequence of significant bits of a given length, intended as a result of anyBits(int).
    default boolean
    Returns any boolean value.
    default byte
    Returns any byte value.
    default char
    Returns any char value of a predefined character set.
    default char
    anyChar(String characters)
    Returns any char value of the given characters.
    default double
    Returns a double value between zero (incl.) and one (excl.).
    default float
    Returns a float value between zero (incl.) and one (excl.).
    default int
    Returns any int value.
    default int
    anyInt(int bound)
    Returns an int value between zero (incl.) and bound (excl.).
    default int
    anyInt(int min, int bound)
    Returns an int value between min (incl.) and bound (excl.).
    default long
    Returns any long value.
    default long
    anyLong(long bound)
    Returns any long value between zero (incl.) and bound (excl.).
    default long
    anyLong(long min, long bound)
    Returns any long value between min (incl.) and bound (excl.).
    default <T extends Enum<T>>
    T
    anyOf(Class<T> enumClass)
    Returns one of the given enum values.
    default <T> T
    anyOf(T... values)
    Returns one of the given values.
    default short
    Returns any short value.
    default BigInteger
    Returns a BigInteger value between zero (incl.) and 216 (excl.).
    default BigInteger
    Returns a BigInteger value between BigInteger.ZERO (incl.) and bound (excl.).
    default int
    anySmallInt(int bound)
    Returns an int value between zero (incl.) and bound (excl.).
    default String
    Returns a String with a length between 1 and 64 consisting of a predefined character set.
    default String
    anyString(int length, String characters)
    Returns a String with the given length consisting of the given characters.
    static Generator
    of(Random random)
    Utility method: Provides a new instance based on a given Random.
  • Method Details

    • anyBits

      static BigInteger anyBits(int numBits, Random random)
      Utility method: Returns a randomly generated non-negative BigInteger representing a sequence of significant bits of a given length, intended as a result of anyBits(int).
    • of

      static Generator of(Random random)
      Utility method: Provides a new instance based on a given Random.
    • anyBoolean

      default boolean anyBoolean()
      Returns any boolean value.

      A typical implementation will return one of {true, false}, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyByte

      default byte anyByte()
      Returns any byte value.

      A typical implementation will return an arbitrary byte value, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyShort

      default short anyShort()
      Returns any short value.

      A typical implementation will return an arbitrary short value, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyInt

      default int anyInt()
      Returns any int value.

      A typical implementation will return an arbitrary int value, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyInt

      default int anyInt(int bound)
      Returns an int value between zero (incl.) and bound (excl.).

      A typical implementation will return an arbitrary int value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyInt

      default int anyInt(int min, int bound)
      Returns an int value between min (incl.) and bound (excl.).

      A typical implementation will return an arbitrary int value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anySmallInt

      default int anySmallInt(int bound)
      Returns an int value between zero (incl.) and bound (excl.).

      A typical implementation will return an arbitrary int value within the defined bounds, with smaller values being more probable than bigger values.

      The default implementation depends on the implementation of anyBits(int).

    • anyLong

      default long anyLong()
      Returns any long value.

      A typical implementation will return an arbitrary long value, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyLong

      default long anyLong(long bound)
      Returns any long value between zero (incl.) and bound (excl.).

      A typical implementation will return an arbitrary long value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyLong

      default long anyLong(long min, long bound)
      Returns any long value between min (incl.) and bound (excl.).

      A typical implementation will return an arbitrary long value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyFloat

      default float anyFloat()
      Returns a float value between zero (incl.) and one (excl.).

      A typical implementation will return an arbitrary long value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyDouble

      default double anyDouble()
      Returns a double value between zero (incl.) and one (excl.).

      A typical implementation will return an arbitrary long value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyBigInteger

      default BigInteger anyBigInteger()
      Returns a BigInteger value between Long.MIN_VALUE and Long.MAX_VALUE (both incl.).

      A typical implementation will return an arbitrary BigInteger value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyBigInteger

      default BigInteger anyBigInteger(BigInteger bound)
      Returns a BigInteger value between BigInteger.ZERO (incl.) and bound (excl.).

      A typical implementation will return an arbitrary BigInteger value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyBigInteger

      default BigInteger anyBigInteger(BigInteger min, BigInteger bound)
      Returns a BigInteger value between min (incl.) and bound (excl.).

      A typical implementation will return an arbitrary BigInteger value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anySmallBigInteger

      default BigInteger anySmallBigInteger()
      Returns a BigInteger value between zero (incl.) and 216 (excl.).

      A typical implementation will return an arbitrary BigInteger value within the defined bounds, with smaller values being more probable than bigger values.

      The default implementation depends on the implementation of anyBits(int).

    • anySmallBigInteger

      default BigInteger anySmallBigInteger(BigInteger bound)
      Returns a BigInteger value between BigInteger.ZERO (incl.) and bound (excl.).

      A typical implementation will return an arbitrary value within the defined bounds, with smaller values being more probable than bigger values.

      The default implementation depends on the implementation of anyBits(int).

    • anyChar

      default char anyChar()
      Returns any char value of a predefined character set.

      A typical implementation will return an arbitrary char value within the predefined character set, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int) and returns one of "0123456789_abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ !#$§%&*+,.?@äöüÄÖÜß".

    • anyChar

      default char anyChar(String characters)
      Returns any char value of the given characters.

      A typical implementation will return an arbitrary char value within the given characters, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

      Parameters:
      characters - A String made up of the characters that are a possible result.
    • anyString

      default String anyString(int length, String characters)
      Returns a String with the given length consisting of the given characters.

      The default implementation depends on the implementation of anyBits(int).

      Parameters:
      length - The length of the resulting string.
      characters - A string made up of the characters that make up a possible result.
    • anyString

      default String anyString()
      Returns a String with a length between 1 and 64 consisting of a predefined character set.

      The default implementation depends on the implementation of anyBits(int) and uses "0123456789_abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ !#$§%&*+,.?@äöüÄÖÜß" as predefined character set.

    • anyOf

      default <T> T anyOf(T... values)
      Returns one of the given values.

      A typical implementation will return an arbitrary value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyOf

      default <T extends Enum<T>> T anyOf(Class<T> enumClass)
      Returns one of the given enum values.

      A typical implementation will return an arbitrary value within the defined bounds, with each possible value being equally probable.

      The default implementation depends on the implementation of anyBits(int).

    • anyBits

      BigInteger anyBits(int numBits)
      Returns any non-negative BigInteger representing a sequence of significant bits of a given length. In other words, the result is any value between zero (inclusive) and 2length (exclusive).

      A typical implementation will return an arbitrary value within the defined bounds, with each possible value being equally probable.