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 StringThe default value.static final intThe maximum generated string length.static final intThe 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 StringGenerationParametersReturns a new instance of generation parameters.@NotNull StringdefaultValue(@NotNull StringGenerationParameters parameters) Returns the default value of the supported type for the specified parameters.protected intrandomSize(@NotNull StringGenerationParameters parameters) Returns a random string length.protected @NotNull StringrandomString(@NotNull StringGenerationParameters parameters) Returns a random sized string.@NotNull StringrandomValue(@NotNull StringGenerationParameters parameters) Returns a random value of the supported type for the specified parameters.booleanChecks if values of the specified type can be generated by this instance.protected voidvalidateParameters(@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, randomValueMethods inherited from class dev.orne.test.rnd.params.AbstractParameterizableGenerator
createEmptyParams, createParams, defaultValue, defaultValue, getExtractor, getParametersType, nullableDefaultValue, nullableDefaultValue, nullableDefaultValue, nullableRandomValue, nullableRandomValue, nullableRandomValue, randomValue, randomValueMethods inherited from class dev.orne.test.rnd.AbstractGenerator
assertSupported, getNullProbability, 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, defaultValue, getPriority, nullableDefaultValue, nullableRandomValue, randomValueMethods 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:
supportsin interfaceGenerator- Overrides:
supportsin 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:
defaultValuein 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:
randomValuein 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:
-