Package org.instancio.generator.lang
Class StringGenerator
- java.lang.Object
-
- org.instancio.generator.AbstractGenerator<String>
-
- org.instancio.generator.lang.StringGenerator
-
- All Implemented Interfaces:
Generator<String>
,GeneratorSpec<String>
,StringGeneratorSpec
public class StringGenerator extends AbstractGenerator<String> implements StringGeneratorSpec
-
-
Constructor Summary
Constructors Constructor Description StringGenerator(GeneratorContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringGeneratorSpec
allowEmpty()
Indicates that an empty string can be generated.StringGeneratorSpec
alphaNumeric()
Generates a mixed case alphanumeric string.StringGeneratorSpec
digits()
Generates a string comprised of only digits.String
generate(RandomProvider random)
Returns a generated value.GeneratedHints
getHints()
Returns hints, including collection sizes and whether values are nullable.StringGeneratorSpec
length(int length)
Length of string to generate.StringGeneratorSpec
lowerCase()
Generates a lower case string.StringGeneratorSpec
maxLength(int length)
Maximum length of string to generate.StringGeneratorSpec
minLength(int length)
Minimum length of string to generate.StringGeneratorSpec
mixedCase()
Generates a mixed case string.StringGeneratorSpec
nullable()
Indicates thatnull
value can be generated.StringGeneratorSpec
prefix(String prefix)
Specifies a String prefix.StringGeneratorSpec
upperCase()
Generates an upper case string.-
Methods inherited from class org.instancio.generator.AbstractGenerator
getContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.instancio.Generator
apiMethodName, isDelegating, setDelegate, supports, targetClass
-
-
-
-
Constructor Detail
-
StringGenerator
public StringGenerator(GeneratorContext context)
-
-
Method Detail
-
prefix
public StringGeneratorSpec prefix(String prefix)
Description copied from interface:StringGeneratorSpec
Specifies a String prefix.- Specified by:
prefix
in interfaceStringGeneratorSpec
- Parameters:
prefix
- for generated strings- Returns:
- spec builder
-
allowEmpty
public StringGeneratorSpec allowEmpty()
Description copied from interface:StringGeneratorSpec
Indicates that an empty string can be generated.- Specified by:
allowEmpty
in interfaceStringGeneratorSpec
- Returns:
- spec builder
-
nullable
public StringGeneratorSpec nullable()
Description copied from interface:StringGeneratorSpec
Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceStringGeneratorSpec
- Returns:
- spec builder
-
length
public StringGeneratorSpec length(int length)
Description copied from interface:StringGeneratorSpec
Length of string to generate.- Specified by:
length
in interfaceStringGeneratorSpec
- Parameters:
length
- exact length to generate- Returns:
- spec builder
-
minLength
public StringGeneratorSpec minLength(int length)
Description copied from interface:StringGeneratorSpec
Minimum length of string to generate.- Specified by:
minLength
in interfaceStringGeneratorSpec
- Parameters:
length
- minimum length (inclusive)- Returns:
- spec builder
-
maxLength
public StringGeneratorSpec maxLength(int length)
Description copied from interface:StringGeneratorSpec
Maximum length of string to generate.- Specified by:
maxLength
in interfaceStringGeneratorSpec
- Parameters:
length
- maximum length (inclusive)- Returns:
- spec builder
-
lowerCase
public StringGeneratorSpec lowerCase()
Description copied from interface:StringGeneratorSpec
Generates a lower case string.- Specified by:
lowerCase
in interfaceStringGeneratorSpec
- Returns:
- spec builder
-
upperCase
public StringGeneratorSpec upperCase()
Description copied from interface:StringGeneratorSpec
Generates an upper case string.- Specified by:
upperCase
in interfaceStringGeneratorSpec
- Returns:
- spec builder
-
mixedCase
public StringGeneratorSpec mixedCase()
Description copied from interface:StringGeneratorSpec
Generates a mixed case string.- Specified by:
mixedCase
in interfaceStringGeneratorSpec
- Returns:
- spec builder
-
alphaNumeric
public StringGeneratorSpec alphaNumeric()
Description copied from interface:StringGeneratorSpec
Generates a mixed case alphanumeric string.- Specified by:
alphaNumeric
in interfaceStringGeneratorSpec
- Returns:
- spec builder
-
digits
public StringGeneratorSpec digits()
Description copied from interface:StringGeneratorSpec
Generates a string comprised of only digits.- Specified by:
digits
in interfaceStringGeneratorSpec
- Returns:
- spec builder
-
generate
public String generate(RandomProvider random)
Description copied from interface:Generator
Returns a generated value.If the generated value is random, it needs to be generated using the given
RandomProvider
instance. This ensures the data is generated with the same seed value and allows random data to be reproduced by specifying the seed value.
-
getHints
public GeneratedHints getHints()
Description copied from interface:Generator
Returns hints, including collection sizes and whether values are nullable.
-
-