Class AbstractTargetedGenerator<T>
- Type Parameters:
T- The type of generated values
- All Implemented Interfaces:
TargetedGenerator<T>
- Direct Known Subclasses:
ConstructorParameterTypeGenerator,MethodParameterTypeGenerator,MethodReturnTypeGenerator,ParameterTypeGenerator,PropertyTypeGenerator
TargetedGenerator.- Since:
- 0.1
- Version:
- 1.0, 2022-11
- Author:
- (w) Iker Hernaez
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractTargetedGenerator(@NotNull Class<T> valueType) Creates a new instance.protectedAbstractTargetedGenerator(@NotNull Class<T> valueType, @NotNull Generator generator) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptiondefaultValue(@NotNull Class<?>... groups) Returns the default value of the supported type.booleanabstract TypeReturns the declared type of the target.protected @NotNull GeneratorReturns the generator to use.getParameterSourceList(@NotNull Class<?>... groups) Returns the generation parameter sources to be used.@NotNull Object[]getParameterSources(@NotNull Class<?>... groups) Returns the generation parameter sources to be used.protected abstract @NotNull Collection<Annotation>getTargetConstraints(@NotNull Class<?>... groups) Returns the constraints of the target for the specified validation groups.Returns the type of generated values.inthashCode()nullableDefaultValue(@NotNull Class<?>... groups) Returns the default value for the specified type allowingnullvalues.nullableRandomValue(@NotNull Class<?>... groups) Returns a random value of the specified type.randomValue(@NotNull Class<?>... groups) Returns a random value of the supported type.
-
Constructor Details
-
AbstractTargetedGenerator
Creates a new instance.- Parameters:
valueType- The type of generated values.
-
AbstractTargetedGenerator
protected AbstractTargetedGenerator(@NotNull @NotNull Class<T> valueType, @NotNull @NotNull Generator generator) Creates a new instance.- Parameters:
valueType- The type of generated values.generator- The generator to use.
-
-
Method Details
-
getValueType
Returns the type of generated values.- Returns:
- The type of generated values.
-
getDeclaredType
Returns the declared type of the target.- Returns:
- The declared type of the target.
-
getGenerator
Returns the generator to use.- Returns:
- The generator to use.
-
defaultValue
Returns the default value of the supported type.If the generator for the type of the target is a
ParameterizableGeneratorextracts the parameters from the constraints of the target when applying the specified validation groups.- Specified by:
defaultValuein interfaceTargetedGenerator<T>- 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 allowingnullvalues.If the generator for the type of the target is a
ParameterizableGeneratorextracts the parameters from the constraints of the target when applying the specified validation groups.This method should return
nullexcept for native types or targets annotated withNotNull.- Specified by:
nullableDefaultValuein interfaceTargetedGenerator<T>- 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
ParameterizableGeneratorextracts the parameters from the constraints of the target when applying the specified validation groups.- Specified by:
randomValuein interfaceTargetedGenerator<T>- 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
ParameterizableGeneratorextracts the parameters from the constraints of the target when applying the specified validation groups.The returned value has a probability of be
nullexcept for native types or targets annotated withNotNull. If notnullbehaves asrandomValue().- Specified by:
nullableRandomValuein interfaceTargetedGenerator<T>- Parameters:
groups- The validation groups to use when extracting the constraints of the target.- Returns:
- A random nullable value.
- See Also:
-
getParameterSources
Returns the generation parameter sources to be used.The specified validation groups will be used to retrieve the constraints to use as sources.
- Specified by:
getParameterSourcesin interfaceTargetedGenerator<T>- Parameters:
groups- The validation groups.- Returns:
- The generation parameter sources.
-
getParameterSourceList
@NotNull protected @NotNull List<Object> getParameterSourceList(@NotNull @NotNull Class<?>... groups) 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
-
getTargetConstraints
@NotNull protected abstract @NotNull Collection<Annotation> getTargetConstraints(@NotNull @NotNull Class<?>... groups) Returns the constraints of the target for the specified validation groups.- Parameters:
groups- The validation groups to use when extracting the constraints of the target- Returns:
- The constraints of the target
-
hashCode
public int hashCode() -
equals
-