Package dev.orne.test.rnd.params
Class AbstractParameterizableGenerator<P extends GenerationParameters>
java.lang.Object
dev.orne.test.rnd.AbstractGenerator
dev.orne.test.rnd.params.AbstractParameterizableGenerator<P>
- Type Parameters:
P- The parameters type
- All Implemented Interfaces:
Generator,ParameterizableGenerator
- Direct Known Subclasses:
AbstractTypedParameterizableGenerator
@API(status=EXPERIMENTAL,
since="0.1")
public abstract class AbstractParameterizableGenerator<P extends GenerationParameters>
extends AbstractGenerator
implements ParameterizableGenerator
Abstract implementation of
ParameterizableGenerator.- Since:
- 0.1
- Version:
- 1.0, 2022-11
- Author:
- (w) Iker Hernaez
-
Field Summary
Fields inherited from class dev.orne.test.rnd.AbstractGenerator
DEFAULT_NULL_PROBABILITY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCrates a new instance.protectedAbstractParameterizableGenerator(@NotNull Class<P> paramsType) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new empty instance of generation parameters.createParams(@NotNull Object... sources) Creates a new instance of generation parameters with the values extracted from the specified sources.<T> TdefaultValue(@NotNull Class<T> type) Returns the default value for the specified type.<T> TdefaultValue(@NotNull Class<T> type, @NotNull Object... sources) Returns the default value for the specified type and parameter sources.abstract <T> TdefaultValue(@NotNull Class<T> type, P parameters) Returns the default value for the specified type and parameters.boolean@NotNull ParametersExtractor<P>Returns the generation parameters extractor.Returns the type of generation parameters.inthashCode()<T> TnullableDefaultValue(@NotNull Class<T> type) Returns the default value for the specified type allowingnullvalues.<T> TnullableDefaultValue(@NotNull Class<T> type, @NotNull Object... sources) Returns the default value for the specified type and parameter sources allowingnullvalues.<T> TnullableDefaultValue(@NotNull Class<T> type, P parameters) Returns the default value for the specified type and parameters allowingnullvalues.<T> TnullableRandomValue(@NotNull Class<T> type) Returns a random value of the specified type allowingnullvalues.<T> TnullableRandomValue(@NotNull Class<T> type, @NotNull Object... sources) Returns a random value of the specified type and parameter sources.<T> TnullableRandomValue(@NotNull Class<T> type, P parameters) Returns a random value of the specified type and parameters.<T> TrandomValue(@NotNull Class<T> type) Returns a random value of the specified type.<T> TrandomValue(@NotNull Class<T> type, @NotNull Object... sources) Returns a random value of the specified type and parameter sources.abstract <T> TrandomValue(@NotNull Class<T> type, P parameters) Returns a random value of the specified type and parameters.Methods inherited from class dev.orne.test.rnd.AbstractGenerator
assertSupported, getNullProbability, randomNull, setNullProbability, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.orne.test.rnd.Generator
asParameterizable, getPriority, supports
-
Constructor Details
-
AbstractParameterizableGenerator
Creates a new instance.- Parameters:
paramsType- The type of parameters
-
AbstractParameterizableGenerator
protected AbstractParameterizableGenerator()Crates a new instance.
-
-
Method Details
-
getParametersType
Returns the type of generation parameters.- Returns:
- The type of generation parameters
-
getExtractor
Returns the generation parameters extractor.- Returns:
- The generation parameters extractor
-
defaultValue
Returns the default value for the specified type.- Specified by:
defaultValuein interfaceGenerator- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.- Returns:
- The default value for the specified type.
-
defaultValue
@NotNull public <T> T defaultValue(@NotNull @NotNull Class<T> type, @NotNull @NotNull Object... sources) Returns the default value for the specified type and parameter sources.- Specified by:
defaultValuein interfaceParameterizableGenerator- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.sources- The parameter sources to extract the parameters from- Returns:
- The default value for the specified type.
-
defaultValue
Returns the default value for the specified type and parameters.- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.parameters- The generation parameters- Returns:
- The default value for the specified type.
- Throws:
IllegalArgumentException- If the specified type is not supported.
-
nullableDefaultValue
Returns the default value for the specified type allowingnullvalues.This method should return
nullexcept for native types.- Specified by:
nullableDefaultValuein interfaceGenerator- Overrides:
nullableDefaultValuein classAbstractGenerator- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.- Returns:
- The nullable default value for the specified type.
-
nullableDefaultValue
public <T> T nullableDefaultValue(@NotNull @NotNull Class<T> type, @NotNull @NotNull Object... sources) Returns the default value for the specified type and parameter sources allowingnullvalues.This method should return
nullexcept for native types when noNotNullconstraint is present.- Specified by:
nullableDefaultValuein interfaceParameterizableGenerator- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.sources- The parameter sources to extract the parameters from- Returns:
- The nullable default value for the specified type.
-
nullableDefaultValue
Returns the default value for the specified type and parameters allowingnullvalues.This method should return
nullexcept for native types when noNotNullconstraint is present.- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.parameters- The generation parameters- Returns:
- The nullable default value for the specified type.
- Throws:
IllegalArgumentException- If the specified type is not supported.
-
randomValue
Returns a random value of the specified type.- Specified by:
randomValuein interfaceGenerator- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.- Returns:
- A random value for the specified type.
-
randomValue
@NotNull public <T> T randomValue(@NotNull @NotNull Class<T> type, @NotNull @NotNull Object... sources) Returns a random value of the specified type and parameter sources.- Specified by:
randomValuein interfaceParameterizableGenerator- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.sources- The parameter sources to extract the parameters from- Returns:
- A random value for the specified type.
-
randomValue
Returns a random value of the specified type and parameters.- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.parameters- The generation parameters- Returns:
- A random value for the specified type.
- Throws:
IllegalArgumentException- If the specified type is not supported.
-
nullableRandomValue
Returns a random value of the specified type allowingnullvalues.The returned value has a probability of be
nullexcept for native types. If notnullbehaves asrandomValue().- Specified by:
nullableRandomValuein interfaceGenerator- Overrides:
nullableRandomValuein classAbstractGenerator- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.- Returns:
- A random nullable value for the specified type.
- See Also:
-
nullableRandomValue
public <T> T nullableRandomValue(@NotNull @NotNull Class<T> type, @NotNull @NotNull Object... sources) Returns a random value of the specified type and parameter sources.The returned value has a probability of be
nullexcept for native types when noNotNullconstraint is present. If notnullbehaves asrandomValue().- Specified by:
nullableRandomValuein interfaceParameterizableGenerator- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.sources- The parameter sources to extract the parameters from- Returns:
- A random nullable value for the specified type.
- See Also:
-
nullableRandomValue
Returns a random value of the specified type and parameters.The returned value has a probability of be
nullexcept for native types when noNotNullconstraint is present. If notnullbehaves asrandomValue().- Type Parameters:
T- The requested value type.- Parameters:
type- The requested value type.parameters- The generation parameters- Returns:
- A random nullable value for the specified type.
- Throws:
IllegalArgumentException- If the specified type is not supported.- See Also:
-
createEmptyParams
Creates a new empty instance of generation parameters.- Returns:
- A new empty instance of generation parameters.
-
createParams
Creates a new instance of generation parameters with the values extracted from the specified sources.- Parameters:
sources- The sources to extract the parameters values from- Returns:
- A new instance of generation parameters.
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractGenerator
-
equals
- Overrides:
equalsin classAbstractGenerator
-