Package org.jeasy.random
Class EasyRandom
java.lang.Object
java.util.Random
org.jeasy.random.EasyRandom
- All Implemented Interfaces:
Serializable,java.util.random.RandomGenerator
Extension of
Random that is able to generate random Java objects.- Author:
- Mahmoud Ben Hassine ([email protected])
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
java.util.random.RandomGenerator.ArbitrarilyJumpableGenerator, java.util.random.RandomGenerator.JumpableGenerator, java.util.random.RandomGenerator.LeapableGenerator, java.util.random.RandomGenerator.SplittableGenerator, java.util.random.RandomGenerator.StreamableGenerator -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newEasyRandominstance with default parameters.EasyRandom(EasyRandomParameters easyRandomParameters) Create a newEasyRandominstance. -
Method Summary
Modifier and TypeMethodDescription<T> TnextObject(Class<T> type) Generate a random instance of the given type.<T> java.util.stream.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, setSeedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.random.RandomGenerator
isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextInt, nextLong, nextLong
-
Constructor Details
-
EasyRandom
public EasyRandom()Create a newEasyRandominstance with default parameters. -
EasyRandom
Create a newEasyRandominstance.- Parameters:
easyRandomParameters- randomization parameters
-
-
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
-