Package org.apache.commons.text
Interface TextRandomProvider
-
- All Superinterfaces:
java.util.function.IntUnaryOperator
public interface TextRandomProvider extends java.util.function.IntUnaryOperator
TextRandomProvider implementations are used byRandomStringGeneratoras a source of randomness. It is highly recommended that the Apache Commons RNG library be used to provide the random number generation.TextRandomProvideris 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
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default intapplyAsInt(int max)Generates an int value between 0 (inclusive) and the specified value (exclusive).intnextInt(int max)Deprecated.UseapplyAsInt(int).
-
-
-
Method Detail
-
applyAsInt
default int applyAsInt(int max)
Generates an int value between 0 (inclusive) and the specified value (exclusive).- Specified by:
applyAsIntin interfacejava.util.function.IntUnaryOperator- Parameters:
max- Bound on the random number to be returned. Must be positive.- Returns:
- a random int value between 0 (inclusive) and max (exclusive).
- Since:
- 1.14.0
-
nextInt
@Deprecated int nextInt(int max)
Deprecated.UseapplyAsInt(int).Generates an int value between 0 (inclusive) and the specified value (exclusive).- Parameters:
max- Bound on the random number to be returned. Must be positive.- Returns:
- a random int value between 0 (inclusive) and max (exclusive).
-
-