Interface TargetedGenerator<T>
- Type Parameters:
T
- The type of the target
- All Known Implementing Classes:
AbstractTargetedGenerator
,ConstructorParameterTypeGenerator
,MethodParameterTypeGenerator
,MethodReturnTypeGenerator
,ParameterTypeGenerator
,PropertyTypeGenerator
- Since:
- 0.1
- Version:
- 1.0, 2022-11
- Author:
- (w) Iker Hernaez
-
Method Summary
Modifier and TypeMethodDescriptiondefaultValue
(@NotNull Class<?>... groups) Returns the default value of the supported type.@NotNull Object[]
getParameterSources
(@NotNull Class<?>... groups) Returns the generation parameter sources to be used.nullableDefaultValue
(@NotNull Class<?>... groups) Returns the default value for the specified type allowingnull
values.nullableRandomValue
(@NotNull Class<?>... groups) Returns a random value of the specified type.randomValue
(@NotNull Class<?>... groups) Returns a random value of the supported type.
-
Method Details
-
getParameterSources
Returns the generation parameter sources to be used.The specified validation groups will be used to retrieve the constraints to use as sources.
- Parameters:
groups
- The validation groups.- Returns:
- The generation parameter sources.
-
defaultValue
Returns the default value of the supported type.If the generator for the type of the target is a
ParameterizableGenerator
extracts the parameters from the constraints of the target when applying the specified validation groups.- Parameters:
groups
- The validation groups to use when extracting the constraints of the target.- Returns:
- The default value.
-
nullableDefaultValue
Returns the default value for the specified type allowingnull
values.If the generator for the type of the target is a
ParameterizableGenerator
extracts the parameters from the constraints of the target when applying the specified validation groups.This method should return
null
except for native types or targets annotated withNotNull
.- Parameters:
groups
- The validation groups to use when extracting the constraints of the target.- Returns:
- The nullable default value for the specified type.
-
randomValue
Returns a random value of the supported type.If the generator for the type of the target is a
ParameterizableGenerator
extracts the parameters from the constraints of the target when applying the specified validation groups.- Parameters:
groups
- The validation groups to use when extracting the constraints of the target- Returns:
- A random value.
-
nullableRandomValue
Returns a random value of the specified type.If the generator for the type of the target is a
ParameterizableGenerator
extracts the parameters from the constraints of the target when applying the specified validation groups.The returned value has a probability of be
null
except for native types or targets annotated withNotNull
. If notnull
behaves asrandomValue()
.- Parameters:
groups
- The validation groups to use when extracting the constraints of the target.- Returns:
- A random nullable value.
- See Also:
-