public static final class RandomInputStream.Builder extends Object
random input streams
.Modifier and Type | Method and Description |
---|---|
RandomInputStream |
build()
Creates a new
random input stream with the settings from this builder. |
<R> R |
transform(Function<? super RandomInputStream.Builder,? extends R> f)
This method allows the application of a function to this builder object.
|
RandomInputStream.Builder |
withLimit(long limit)
Specifies the maximum number of bytes to return while reading.
|
RandomInputStream.Builder |
withRandom(Random random)
Specifies the random to use.
|
RandomInputStream.Builder |
withRandomLimit(int min,
int max)
Specifies that a random number should be used for the maximum number of bytes to return while reading.
|
public RandomInputStream.Builder withRandom(Random random)
SecureRandom
will be created.random
- The random to use.NullPointerException
- If the given random is null
.public RandomInputStream.Builder withLimit(long limit)
Calling this method will discard any changes made by withRandomLimit(int, int)
.
limit
- The limit to set.public RandomInputStream.Builder withRandomLimit(int min, int max)
Calling this method will cause any changes made by withLimit(long)
to be ignored.
min
- The minimum allowed limit, inclusive.max
- The maximum allowed limit, exclusive.IllegalArgumentException
- If the minimum is negative, or the maximum is not larger than the minimum.public <R> R transform(Function<? super RandomInputStream.Builder,? extends R> f)
Any exception thrown by the function will be propagated to the caller.
R
- The type of the result of the function.f
- The function to apply.public RandomInputStream build()
random input stream
with the settings from this builder.Copyright © 2020–2024. All rights reserved.