Class OptionalRandomizer<T>
- java.lang.Object
-
- org.jeasy.random.randomizers.AbstractRandomizer<T>
-
- org.jeasy.random.randomizers.misc.OptionalRandomizer<T>
-
- Type Parameters:
T- the type generated by this randomizer
- All Implemented Interfaces:
Randomizer<T>
public class OptionalRandomizer<T> extends AbstractRandomizer<T>
ARandomizerwhich, according to the optional percent, returns the random value from a delegate.- Author:
- Eric Taix (eric.taix@gmail.com)
-
-
Field Summary
-
Fields inherited from class org.jeasy.random.randomizers.AbstractRandomizer
random
-
-
Constructor Summary
Constructors Constructor Description OptionalRandomizer(Randomizer<T> delegate, int optionalPercent)Create a newOptionalRandomizerwith a delegate randomizer and an optional percent threshold.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TgetRandomValue()Generate a random value for the given type.-
Methods inherited from class org.jeasy.random.randomizers.AbstractRandomizer
getPredefinedValuesOf, nextDouble, toString
-
-
-
-
Constructor Detail
-
OptionalRandomizer
public OptionalRandomizer(Randomizer<T> delegate, int optionalPercent)
Create a newOptionalRandomizerwith a delegate randomizer and an optional percent threshold.- Parameters:
delegate- The delegate to use to retrieve a random valueoptionalPercent- The percent of randomized value to return (between 0 and 100)
-
-
Method Detail
-
getRandomValue
public T getRandomValue()
Description copied from interface:RandomizerGenerate a random value for the given type.- Returns:
- a random value for the given type
-
-