Package dev.orne.test.rnd.params
Class FactoryMethodGenerator<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.FactoryMethodGenerator<T>
- Type Parameters:
T- The type of generated values
- All Implemented Interfaces:
Generator,TypedGenerator<T>
@API(status=EXPERIMENTAL,
since="0.1")
public class FactoryMethodGenerator<T>
extends ExecutableGenerator<T>
Generator that calls a static factory method 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
ConstructorsModifierConstructorDescriptionprotectedFactoryMethodGenerator(@NotNull Class<T> type, @NotNull Method method, @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> FactoryMethodGenerator<T>Creates a new instance that will call the specified factory method.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
-
FactoryMethodGenerator
protected FactoryMethodGenerator(@NotNull @NotNull Class<T> type, @NotNull @NotNull Method method, @NotNull @NotNull TargetedGenerator<?>[] paramGenerators) Creates a new instance.- Parameters:
type- The type of generated valuesmethod- The factory method to callparamGenerators- The parameter generators
-
-
Method Details
-
of
public static <T> FactoryMethodGenerator<T> of(@NotNull @NotNull Class<T> type, @NotNull @NotNull Method method) Creates a new instance that will call the specified factory method.- Type Parameters:
T- The type of the generated instance- Parameters:
type- The type of generated valuesmethod- The factory method 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
-