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 Object
nullableRandomComponent
(@NotNull Type type) Returns a random value of the specified type allowingnull
values.static @NotNull Object
randomComponent
(@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 allowingnull
values.The returned value has a probability of be
null
except for native types. If notnull
behaves 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.
-