Package org.jeasy.random.api
Interface RandomizerProvider
public interface RandomizerProvider
Strategy interface to provide randomizers for field/type based on the current context.
Implementations may (or may not) use registries to provide randomizers.
The added value of this interface compared to a simple RandomizerRegistry is that it
gives access to the current context and allows fine grained randomizer selection based on that
context.
- Author:
- Mahmoud Ben Hassine ([email protected])
-
Method Summary
Modifier and TypeMethodDescriptiondefault Randomizer<?>getRandomizerByField(Field field, RandomizerContext context) Return a randomizer for the given field in the current context.default <T> Randomizer<T>getRandomizerByType(Class<T> type, RandomizerContext context) Return a randomizer for the given type in the current context.default voidsetRandomizerRegistries(Set<RandomizerRegistry> randomizerRegistries) Set randomizer registries.
-
Method Details
-
getRandomizerByField
Return a randomizer for the given field in the current context.- Parameters:
field- for which a randomizer should be returnedcontext- current randomization context- Returns:
- a randomizer for the given field in the current context.
-
getRandomizerByType
Return a randomizer for the given type in the current context.- Type Parameters:
T- generic type- Parameters:
type- for which a randomizer should be returnedcontext- current randomization context- Returns:
- a randomizer for the given type in the current context.
-
setRandomizerRegistries
Set randomizer registries.- Parameters:
randomizerRegistries- to set
-