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
ConstructorsModifierConstructorDescriptionprotected
Crates a new instance.protected
AbstractParameterizableGenerator
(@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> T
defaultValue
(@NotNull Class<T> type) Returns the default value for the specified type.<T> T
defaultValue
(@NotNull Class<T> type, @NotNull Object... sources) Returns the default value for the specified type and parameter sources.abstract <T> T
defaultValue
(@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.int
hashCode()
<T> T
nullableDefaultValue
(@NotNull Class<T> type) Returns the default value for the specified type allowingnull
values.<T> T
nullableDefaultValue
(@NotNull Class<T> type, @NotNull Object... sources) Returns the default value for the specified type and parameter sources allowingnull
values.<T> T
nullableDefaultValue
(@NotNull Class<T> type, P parameters) Returns the default value for the specified type and parameters allowingnull
values.<T> T
nullableRandomValue
(@NotNull Class<T> type) Returns a random value of the specified type allowingnull
values.<T> T
nullableRandomValue
(@NotNull Class<T> type, @NotNull Object... sources) Returns a random value of the specified type and parameter sources.<T> T
nullableRandomValue
(@NotNull Class<T> type, P parameters) Returns a random value of the specified type and parameters.<T> T
randomValue
(@NotNull Class<T> type) Returns a random value of the specified type.<T> T
randomValue
(@NotNull Class<T> type, @NotNull Object... sources) Returns a random value of the specified type and parameter sources.abstract <T> T
randomValue
(@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, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:
defaultValue
in 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:
defaultValue
in 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 allowingnull
values.This method should return
null
except for native types.- Specified by:
nullableDefaultValue
in interfaceGenerator
- Overrides:
nullableDefaultValue
in 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 allowingnull
values.This method should return
null
except for native types when noNotNull
constraint is present.- Specified by:
nullableDefaultValue
in 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 allowingnull
values.This method should return
null
except for native types when noNotNull
constraint 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:
randomValue
in 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:
randomValue
in 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 allowingnull
values.The returned value has a probability of be
null
except for native types. If notnull
behaves asrandomValue()
.- Specified by:
nullableRandomValue
in interfaceGenerator
- Overrides:
nullableRandomValue
in 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
null
except for native types when noNotNull
constraint is present. If notnull
behaves asrandomValue()
.- Specified by:
nullableRandomValue
in 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
null
except for native types when noNotNull
constraint is present. If notnull
behaves 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:
hashCode
in classAbstractGenerator
-
equals
- Overrides:
equals
in classAbstractGenerator
-