Package dev.orne.test.rnd.params
Class ConstructorGenerator<T>
java.lang.Object
dev.orne.test.rnd.AbstractGenerator
dev.orne.test.rnd.AbstractTypedGenerator<T>
dev.orne.test.rnd.params.ExecutableGenerator<T>
dev.orne.test.rnd.params.ConstructorGenerator<T>
- Type Parameters:
T- The type of generated values
- All Implemented Interfaces:
Generator,TypedGenerator<T>
@API(status=EXPERIMENTAL,
since="0.1")
public class ConstructorGenerator<T>
extends ExecutableGenerator<T>
Generator that calls a constructor with generated parameters to
generate values of the target type.
- Since:
- 0.1
- Version:
- 1.0, 2022-12
- Author:
- (w) Iker Hernaez
-
Field Summary
Fields inherited from class dev.orne.test.rnd.AbstractGenerator
DEFAULT_NULL_PROBABILITY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructorGenerator(@NotNull Constructor<T> constructor, @NotNull TargetedGenerator<?>[] paramGenerators) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected TCalls the executable to create a new instance of the target type.Returns the executable to call.static <T> ConstructorGenerator<T>of(@NotNull Constructor<T> constructor) Creates a new instance that will call the specified constructor.Methods inherited from class dev.orne.test.rnd.params.ExecutableGenerator
defaultValue, equals, getParameterGenerators, hashCode, of, randomValueMethods inherited from class dev.orne.test.rnd.AbstractTypedGenerator
defaultValue, getValueType, nullableDefaultValue, nullableRandomValue, randomValue, supportsMethods inherited from class dev.orne.test.rnd.AbstractGenerator
assertSupported, getNullProbability, nullableDefaultValue, nullableRandomValue, 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, nullableDefaultValue, nullableRandomValue
-
Constructor Details
-
ConstructorGenerator
protected ConstructorGenerator(@NotNull @NotNull Constructor<T> constructor, @NotNull @NotNull TargetedGenerator<?>[] paramGenerators) Creates a new instance.- Parameters:
constructor- The constructor to callparamGenerators- The parameter generators
-
-
Method Details
-
of
Creates a new instance that will call the specified constructor.- Type Parameters:
T- The type of the generated instance- Parameters:
constructor- The constructor to call- Returns:
- The created generator
-
getExecutable
Returns the executable to call.- Overrides:
getExecutablein classExecutableGenerator<T>- Returns:
- The executable to call
-
generate
Calls the executable to create a new instance of the target type.- Specified by:
generatein classExecutableGenerator<T>- Parameters:
params- The parameters to use when calling the executable- Returns:
- The created instance
-