Package io.github.krandom
Class KRandom
java.lang.Object
java.util.Random
io.github.krandom.KRandom
- All Implemented Interfaces:
Serializable
,RandomGenerator
Extension of
Random
that is able to generate random Java objects.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator
-
Constructor Summary
ConstructorsConstructorDescriptionKRandom()
Create a newKRandom
instance with default parameters.KRandom
(KRandomParameters kRandomParameters) Create a newKRandom
instance. -
Method Summary
Modifier and TypeMethodDescription<T> T
nextObject
(Class<T> type) Generate a random instance of the given type.<T> Stream<T>
Generate a stream of random instances of the given type.Methods inherited from class java.util.Random
doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, next, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeed
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.random.RandomGenerator
isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextInt, nextLong, nextLong
-
Constructor Details
-
Method Details
-
nextObject
Generate a random instance of the given type.- Type Parameters:
T
- the actual type of the target object- Parameters:
type
- the type for which an instance will be generated- Returns:
- a random instance of the given type
- Throws:
ObjectCreationException
- when unable to create a new instance of the given type
-
objects
Generate a stream of random instances of the given type.- Type Parameters:
T
- the actual type of the target objects- Parameters:
type
- the type for which instances will be generatedstreamSize
- the number of instances to generate- Returns:
- a stream of random instances of the given type
- Throws:
ObjectCreationException
- when unable to create a new instance of the given type
-