Package dev.orne.test.rnd.generators
Class CollectionGeneratorUtils
java.lang.Object
dev.orne.test.rnd.generators.CollectionGeneratorUtils
Utility class for generating components for generic types.
- Since:
- 0.1
- Version:
- 1.0, 2022-12
- Author:
- (w) Iker Hernaez
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ObjectnullableRandomComponent(@NotNull Type type) Returns a random value of the specified type allowingnullvalues.static @NotNull ObjectrandomComponent(@NotNull Type type) Returns a random value of the specified type.
-
Method Details
-
randomComponent
Returns a random value of the specified type.- Parameters:
type- The requested value type.- Returns:
- A random value for the specified type.
- Throws:
GeneratorNotFoundException- If no generator supports the requested value type.GeneratorNotParameterizableException- If the component type is a parameterized type and the generator registered for the raw class is not parameterizable.
-
nullableRandomComponent
Returns a random value of the specified type allowingnullvalues.The returned value has a probability of be
nullexcept for native types. If notnullbehaves asrandomValue().- Parameters:
type- The requested value type.- Returns:
- A random nullable value for the specified type.
- Throws:
GeneratorNotFoundException- If no generator supports the requested value type.GeneratorNotParameterizableException- If the component type is a parameterized type and the generator registered for the raw class is not parameterizable.
-