Package dev.orne.test.rnd.generators
Class StringGenerator
java.lang.Object
dev.orne.test.rnd.AbstractGenerator
dev.orne.test.rnd.params.AbstractParameterizableGenerator<P>
dev.orne.test.rnd.params.AbstractTypedParameterizableGenerator<String,StringGenerationParameters>
dev.orne.test.rnd.generators.StringGenerator
- All Implemented Interfaces:
Generator
,ParameterizableGenerator
,TypedParameterizableGenerator<String>
,TypedGenerator<String>
@API(status=STABLE,
since="0.1")
@Priority(-1000)
public class StringGenerator
extends AbstractTypedParameterizableGenerator<String,StringGenerationParameters>
Generator of
String
and CharSequence
values.- Since:
- 0.1
- Version:
- 1.0, 2022-10
- Author:
- (w) Iker Hernaez
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The default value.static final int
The maximum generated string length.static final int
The minimum generated string length.Fields inherited from class dev.orne.test.rnd.AbstractGenerator
DEFAULT_NULL_PROBABILITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull StringGenerationParameters
Returns a new instance of generation parameters.@NotNull String
defaultValue
(@NotNull StringGenerationParameters parameters) Returns the default value of the supported type for the specified parameters.protected int
randomSize
(@NotNull StringGenerationParameters parameters) Returns a random string length.protected @NotNull String
randomString
(@NotNull StringGenerationParameters parameters) Returns a random sized string.@NotNull String
randomValue
(@NotNull StringGenerationParameters parameters) Returns a random value of the supported type for the specified parameters.boolean
Checks if values of the specified type can be generated by this instance.protected void
validateParameters
(@NotNull StringGenerationParameters parameters) Validates that the parameters contain enough information to generate the values.Methods inherited from class dev.orne.test.rnd.params.AbstractTypedParameterizableGenerator
defaultValue, defaultValue, defaultValue, equals, getValueType, hashCode, nullableDefaultValue, nullableDefaultValue, nullableDefaultValue, nullableRandomValue, nullableRandomValue, nullableRandomValue, randomValue, randomValue, randomValue
Methods inherited from class dev.orne.test.rnd.params.AbstractParameterizableGenerator
createEmptyParams, createParams, defaultValue, defaultValue, getExtractor, getParametersType, nullableDefaultValue, nullableDefaultValue, nullableDefaultValue, nullableRandomValue, nullableRandomValue, nullableRandomValue, randomValue, randomValue
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, defaultValue, getPriority, nullableDefaultValue, nullableRandomValue, randomValue
Methods inherited from interface dev.orne.test.rnd.params.ParameterizableGenerator
defaultValue, nullableDefaultValue, nullableRandomValue, randomValue
-
Field Details
-
DEFAULT_VALUE
The default value.- See Also:
-
MIN_SIZE
public static final int MIN_SIZEThe minimum generated string length.- See Also:
-
MAX_SIZE
public static final int MAX_SIZEThe maximum generated string length.- See Also:
-
-
Constructor Details
-
StringGenerator
public StringGenerator()Creates a new instance.
-
-
Method Details
-
supports
Checks if values of the specified type can be generated by this instance.- Specified by:
supports
in interfaceGenerator
- Overrides:
supports
in classAbstractTypedParameterizableGenerator<String,
StringGenerationParameters> - Parameters:
type
- The type to check.- Returns:
- If values of the specified type can be generated.
-
defaultValue
@NotNull public @NotNull String defaultValue(@NotNull @NotNull StringGenerationParameters parameters) Returns the default value of the supported type for the specified parameters.- Specified by:
defaultValue
in classAbstractTypedParameterizableGenerator<String,
StringGenerationParameters> - Parameters:
parameters
- The generation parameters- Returns:
- The default value.
-
randomValue
@NotNull public @NotNull String randomValue(@NotNull @NotNull StringGenerationParameters parameters) Returns a random value of the supported type for the specified parameters.- Specified by:
randomValue
in classAbstractTypedParameterizableGenerator<String,
StringGenerationParameters> - Parameters:
parameters
- The generation parameters- Returns:
- A random value.
-
validateParameters
Validates that the parameters contain enough information to generate the values.- Parameters:
parameters
- The generation parameters.
-
randomString
@NotNull protected @NotNull String randomString(@NotNull @NotNull StringGenerationParameters parameters) Returns a random sized string.- Parameters:
parameters
- The generation parameters.- Returns:
- A random string.
- Throws:
GenerationException
- If an error occurs generating the value
-
randomSize
Returns a random string length.- Parameters:
parameters
- The generation parameters.- Returns:
- The string length.
-
createParameters
Returns a new instance of generation parameters.- Returns:
- The generation parameters.
- See Also:
-