Top Description Methods
org.apache.commons.text

public Interface TextRandomProvider

extends IntUnaryOperator
Imports
java.util.function.IntUnaryOperator

TextRandomProvider implementations are used by RandomStringGenerator as a source of randomness. It is highly recommended that the Apache Commons RNG library be used to provide the random number generation.

TextRandomProvider is a functional interface and need not be explicitly implemented.

For example:

UniformRandomProvider rng = RandomSource.create(...);
RandomStringGenerator gen = RandomStringGenerator.builder()
    .usingRandom(rng::nextInt)
    // additional builder calls as needed
    .build();

Since
1.1

Method Summary

Modifier and TypeMethod and Description
public default int

Returns:

a random int value between 0 (inclusive) and max (exclusive).
applyAsInt
(final int
Bound on the random number to be returned. Must be positive.
max
)

Implements java.util.function.IntUnaryOperator.applyAsInt.

Generates an int value between 0 (inclusive) and the specified value (exclusive).

public int

Returns:

a random int value between 0 (inclusive) and max (exclusive).
nextInt
(int
Bound on the random number to be returned. Must be positive.
max
)
Deprecated Use applyAsInt(int).

Generates an int value between 0 (inclusive) and the specified value (exclusive).

Inherited from java.util.function.IntUnaryOperator:
andThencomposeidentity

Method Detail

applyAsIntback to summary
public default int applyAsInt(final int max)

Implements java.util.function.IntUnaryOperator.applyAsInt.

Generates an int value between 0 (inclusive) and the specified value (exclusive).

Parameters
max:int

Bound on the random number to be returned. Must be positive.

Returns:int

a random int value between 0 (inclusive) and max (exclusive).

Annotations
@Override
Since
1.14.0
nextIntback to summary
public int nextInt(int max)

Deprecated

Use applyAsInt(int).

Generates an int value between 0 (inclusive) and the specified value (exclusive).

Parameters
max:int

Bound on the random number to be returned. Must be positive.

Returns:int

a random int value between 0 (inclusive) and max (exclusive).

Annotations
@Deprecated