Package dev.orne.test.rnd.generators
Class AbstractPrimitiveGenerator<T>
java.lang.Object
dev.orne.test.rnd.AbstractGenerator
dev.orne.test.rnd.AbstractTypedGenerator<T>
dev.orne.test.rnd.generators.AbstractPrimitiveGenerator<T>
- Type Parameters:
T- The primitive wrapper type
- All Implemented Interfaces:
Generator,TypedGenerator<T>
- Direct Known Subclasses:
BooleanGenerator,ByteGenerator,CharacterGenerator,DoubleGenerator,FloatGenerator,IntegerGenerator,LongGenerator,ShortGenerator
@API(status=STABLE,
since="0.1")
public abstract class AbstractPrimitiveGenerator<T>
extends AbstractTypedGenerator<T>
Abstract generator implementation for primitive types.
- Since:
- 0.1
- Version:
- 1.0, 2022-10
- Author:
- (w) Iker Hernaez
-
Field Summary
Fields inherited from class dev.orne.test.rnd.AbstractGenerator
DEFAULT_NULL_PROBABILITY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCrates a new instance.protectedAbstractPrimitiveGenerator(@NotNull Class<T> valueType) Crates a new instance. -
Method Summary
Modifier and TypeMethodDescription<R> RnullableDefaultValue(@NotNull Class<R> type) Returns the default value for the specified type allowingnullvalues.booleanrandomNull(@NotNull Class<?> type) Determines if the value must benullbased on the probability ofnullvalues.booleanChecks if values of the specified type can be generated by this instance.Methods inherited from class dev.orne.test.rnd.AbstractTypedGenerator
defaultValue, equals, getValueType, hashCode, nullableDefaultValue, nullableRandomValue, randomValueMethods inherited from class dev.orne.test.rnd.AbstractGenerator
assertSupported, getNullProbability, nullableRandomValue, 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, nullableRandomValueMethods inherited from interface dev.orne.test.rnd.TypedGenerator
defaultValue, randomValue
-
Constructor Details
-
AbstractPrimitiveGenerator
protected AbstractPrimitiveGenerator()Crates a new instance.Infers generated values type from the generic type arguments of this instance class. The class must extend
AbstractPrimitiveGeneratorspecifying the generic types.Example:
class MyLongGenerator extends AbstractPrimitiveGenerator<Long> { ... } -
AbstractPrimitiveGenerator
Crates a new instance.- Parameters:
valueType- The type of generated values
-
-
Method Details
-
supports
Checks if values of the specified type can be generated by this instance.- Specified by:
supportsin interfaceGenerator- Overrides:
supportsin classAbstractTypedGenerator<T>- Parameters:
type- The type to check.- Returns:
- If values of the specified type can be generated.
-
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:
R- The requested value type.- Parameters:
type- The requested value type.- Returns:
- The nullable default value for the specified type.
-
randomNull
Determines if the value must benullbased on the probability ofnullvalues.Overriding classes can use the type parameter to detect non nullable types (like primitives).
- Overrides:
randomNullin classAbstractGenerator- Parameters:
type- The requested value type- Returns:
- If the value must be
null - See Also:
-