Class StringGenerator
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<String>
org.instancio.internal.generator.lang.StringGenerator
- All Implemented Interfaces:
Generator<String>
,GeneratorSpec<String>
,NullableGeneratorSpec<String>
,StringGeneratorSpec
,StringSpec
,ValueSpec<String>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionIndicates that an empty string can be generated.allowEmpty
(boolean isAllowed) Indicates if empty string can be generated.Generates a mixed case alphanumeric string.Returns the public API method name of the generator spec.digits()
Generates a string comprised of only digits.Returns a generated value.final int
length
(int length) Length of string to generate.length
(int minLength, int maxLength) Length of string to generate.Generates a lower case string.maxLength
(int length) Maximum length of string to generate.minLength
(int length) Minimum length of string to generate.Generates a mixed case string.nullable()
Indicates thatnull
value can be generated.nullable
(boolean isNullable) Specifies a String prefix.void
setDelegate
(Generator<?> delegate) Specifes a String suffix.Generates an upper case string.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
getContext, hints, isNullable
-
Field Details
-
minLength
protected int minLength -
maxLength
protected int maxLength
-
-
Constructor Details
-
StringGenerator
public StringGenerator() -
StringGenerator
-
-
Method Details
-
setDelegate
-
getMinLength
public final int getMinLength() -
apiMethod
Description copied from class:AbstractGenerator
Returns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethod
in classAbstractGenerator<String>
- Returns:
- spec name if defined, or
null
otherwise
-
prefix
Description copied from interface:StringGeneratorSpec
Specifies a String prefix.- Specified by:
prefix
in interfaceStringGeneratorSpec
- Specified by:
prefix
in interfaceStringSpec
- Parameters:
prefix
- for generated strings- Returns:
- spec builder
-
suffix
Description copied from interface:StringGeneratorSpec
Specifes a String suffix.- Specified by:
suffix
in interfaceStringGeneratorSpec
- Specified by:
suffix
in interfaceStringSpec
- Parameters:
suffix
- for generated strings- Returns:
- spec builder
-
allowEmpty
Description copied from interface:StringGeneratorSpec
Indicates that an empty string can be generated.- Specified by:
allowEmpty
in interfaceStringGeneratorSpec
- Specified by:
allowEmpty
in interfaceStringSpec
- Returns:
- spec builder
-
allowEmpty
Description copied from interface:StringGeneratorSpec
Indicates if empty string can be generated.- Specified by:
allowEmpty
in interfaceStringGeneratorSpec
- Specified by:
allowEmpty
in interfaceStringSpec
- Parameters:
isAllowed
- iftrue
, empty strings can be generated- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpec
Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceNullableGeneratorSpec<String>
- Specified by:
nullable
in interfaceStringGeneratorSpec
- Specified by:
nullable
in interfaceStringSpec
- Overrides:
nullable
in classAbstractGenerator<String>
- Returns:
- spec builder
-
nullable
- Overrides:
nullable
in classAbstractGenerator<String>
-
length
Description copied from interface:StringGeneratorSpec
Length of string to generate.- Specified by:
length
in interfaceStringGeneratorSpec
- Specified by:
length
in interfaceStringSpec
- Parameters:
length
- exact length to generate- Returns:
- spec builder
-
length
Description copied from interface:StringGeneratorSpec
Length of string to generate.- Specified by:
length
in interfaceStringGeneratorSpec
- Specified by:
length
in interfaceStringSpec
- Parameters:
minLength
- minimum length (inclusive)maxLength
- maximum length (inclusive)- Returns:
- spec builder
-
minLength
Description copied from interface:StringGeneratorSpec
Minimum length of string to generate.- Specified by:
minLength
in interfaceStringGeneratorSpec
- Specified by:
minLength
in interfaceStringSpec
- Parameters:
length
- minimum length (inclusive)- Returns:
- spec builder
-
maxLength
Description copied from interface:StringGeneratorSpec
Maximum length of string to generate.- Specified by:
maxLength
in interfaceStringGeneratorSpec
- Specified by:
maxLength
in interfaceStringSpec
- Parameters:
length
- maximum length (inclusive)- Returns:
- spec builder
-
lowerCase
Description copied from interface:StringGeneratorSpec
Generates a lower case string.- Specified by:
lowerCase
in interfaceStringGeneratorSpec
- Specified by:
lowerCase
in interfaceStringSpec
- Returns:
- spec builder
-
upperCase
Description copied from interface:StringGeneratorSpec
Generates an upper case string.- Specified by:
upperCase
in interfaceStringGeneratorSpec
- Specified by:
upperCase
in interfaceStringSpec
- Returns:
- spec builder
-
mixedCase
Description copied from interface:StringGeneratorSpec
Generates a mixed case string.- Specified by:
mixedCase
in interfaceStringGeneratorSpec
- Specified by:
mixedCase
in interfaceStringSpec
- Returns:
- spec builder
-
alphaNumeric
Description copied from interface:StringGeneratorSpec
Generates a mixed case alphanumeric string.- Specified by:
alphaNumeric
in interfaceStringGeneratorSpec
- Specified by:
alphaNumeric
in interfaceStringSpec
- Returns:
- spec builder
-
digits
Description copied from interface:StringGeneratorSpec
Generates a string comprised of only digits.- Specified by:
digits
in interfaceStringGeneratorSpec
- Specified by:
digits
in interfaceStringSpec
- Returns:
- spec builder
-
generate
Description copied from interface:Generator
Returns a generated value.If this method produces random data, the data needs to be generated using the provided
Random
instance. This ensures generated values are reproducible for a given seed value.
-