Package dev.orne.test.rnd.generators
Class EnumGenerator
java.lang.Object
dev.orne.test.rnd.AbstractGenerator
dev.orne.test.rnd.generators.EnumGenerator
- All Implemented Interfaces:
Generator
@API(status=STABLE,
since="0.1")
@Priority(-2000)
public class EnumGenerator
extends AbstractGenerator
Generator of enumeration types values.
Requires that the enumeration type contain constants.
- 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
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
defaultValue
(@NotNull Class<T> type) Returns the default value for the specified type.static <T extends Enum<T>>
TrandomEnumValue
(@NotNull Class<T> type) Returns a random constant of the specified enumeration.<T> T
randomValue
(@NotNull Class<T> type) Returns a random value of the specified type.boolean
Checks if values of the specified type can be generated by this instance.Methods inherited from class dev.orne.test.rnd.AbstractGenerator
assertSupported, equals, getNullProbability, hashCode, nullableDefaultValue, nullableRandomValue, 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
-
Constructor Details
-
EnumGenerator
public EnumGenerator()Creates a new instance.
-
-
Method Details
-
supports
Checks if values of the specified type can be generated by this instance.- Parameters:
type
- The type to check.- Returns:
- If values of the specified type can be generated.
-
defaultValue
Returns the default value for the specified type.- Type Parameters:
T
- The requested value type.- Parameters:
type
- The requested value type.- Returns:
- The default value for the specified type.
-
randomValue
Returns a random value of the specified type.- Type Parameters:
T
- The requested value type.- Parameters:
type
- The requested value type.- Returns:
- A random value for the specified type.
-
randomEnumValue
Returns a random constant of the specified enumeration.- Type Parameters:
T
- The enumeration type- Parameters:
type
- The enumeration type- Returns:
- A random enumeration constant
- Throws:
IllegalArgumentException
- If the enumeration has no constants
-