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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIndicates that an empty string can be generated.allowEmpty(boolean isAllowed) Indicates if empty string can be generated.Generates an alphanumeric string, upper case by default.Returns the public API method name of the generator spec.digits()Generates a string comprised of only digits.final inthex()Generates a hexadecimal string, upper case by default.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 thatnullvalue can be generated.nullable(boolean isNullable) Specifies the prefix to prepend to generated strings.voidsetDelegate(Generator<?> delegate) Specifies the suffix to append to generated strings.tryGenerateNonNull(Random random) Makes the best effort to return a non-null value.Generates an upper case string.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
generate, 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:AbstractGeneratorReturns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethodin classAbstractGenerator<String>- Returns:
- spec name if defined, or
nullotherwise
-
prefix
Description copied from interface:StringGeneratorSpecSpecifies the prefix to prepend to generated strings.- Specified by:
prefixin interfaceStringGeneratorSpec- Specified by:
prefixin interfaceStringSpec- Parameters:
prefix- for generated strings- Returns:
- spec builder
-
suffix
Description copied from interface:StringGeneratorSpecSpecifies the suffix to append to generated strings.- Specified by:
suffixin interfaceStringGeneratorSpec- Specified by:
suffixin interfaceStringSpec- Parameters:
suffix- for generated strings- Returns:
- spec builder
-
allowEmpty
Description copied from interface:StringGeneratorSpecIndicates that an empty string can be generated.- Specified by:
allowEmptyin interfaceStringGeneratorSpec- Specified by:
allowEmptyin interfaceStringSpec- Returns:
- spec builder
-
allowEmpty
Description copied from interface:StringGeneratorSpecIndicates if empty string can be generated.- Specified by:
allowEmptyin interfaceStringGeneratorSpec- Specified by:
allowEmptyin interfaceStringSpec- Parameters:
isAllowed- iftrue, empty strings can be generated- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceNullableGeneratorSpec<String>- Specified by:
nullablein interfaceStringGeneratorSpec- Specified by:
nullablein interfaceStringSpec- Specified by:
nullablein interfaceValueSpec<String>- Overrides:
nullablein classAbstractGenerator<String>- Returns:
- spec builder
-
nullable
- Overrides:
nullablein classAbstractGenerator<String>
-
length
Description copied from interface:StringGeneratorSpecLength of string to generate.- Specified by:
lengthin interfaceStringGeneratorSpec- Specified by:
lengthin interfaceStringSpec- Parameters:
length- exact length to generate- Returns:
- spec builder
-
length
Description copied from interface:StringGeneratorSpecLength of string to generate.- Specified by:
lengthin interfaceStringGeneratorSpec- Specified by:
lengthin interfaceStringSpec- Parameters:
minLength- minimum length (inclusive)maxLength- maximum length (inclusive)- Returns:
- spec builder
-
minLength
Description copied from interface:StringGeneratorSpecMinimum length of string to generate.- Specified by:
minLengthin interfaceStringGeneratorSpec- Specified by:
minLengthin interfaceStringSpec- Parameters:
length- minimum length (inclusive)- Returns:
- spec builder
-
maxLength
Description copied from interface:StringGeneratorSpecMaximum length of string to generate.- Specified by:
maxLengthin interfaceStringGeneratorSpec- Specified by:
maxLengthin interfaceStringSpec- Parameters:
length- maximum length (inclusive)- Returns:
- spec builder
-
lowerCase
Description copied from interface:StringGeneratorSpecGenerates a lower case string.- Specified by:
lowerCasein interfaceStringGeneratorSpec- Specified by:
lowerCasein interfaceStringSpec- Returns:
- spec builder
-
upperCase
Description copied from interface:StringGeneratorSpecGenerates an upper case string.- Specified by:
upperCasein interfaceStringGeneratorSpec- Specified by:
upperCasein interfaceStringSpec- Returns:
- spec builder
-
mixedCase
Description copied from interface:StringGeneratorSpecGenerates a mixed case string.- Specified by:
mixedCasein interfaceStringGeneratorSpec- Specified by:
mixedCasein interfaceStringSpec- Returns:
- spec builder
-
alphaNumeric
Description copied from interface:StringGeneratorSpecGenerates an alphanumeric string, upper case by default.- Specified by:
alphaNumericin interfaceStringGeneratorSpec- Specified by:
alphaNumericin interfaceStringSpec- Returns:
- spec builder
-
digits
Description copied from interface:StringGeneratorSpecGenerates a string comprised of only digits.- Specified by:
digitsin interfaceStringGeneratorSpec- Specified by:
digitsin interfaceStringSpec- Returns:
- spec builder
-
hex
Description copied from interface:StringSpecGenerates a hexadecimal string, upper case by default.- Specified by:
hexin interfaceStringGeneratorSpec- Specified by:
hexin interfaceStringSpec- Returns:
- spec builder
-
tryGenerateNonNull
Description copied from class:AbstractGeneratorMakes the best effort to return a non-null value. However, in certain cases this method will produce anull.- Specified by:
tryGenerateNonNullin classAbstractGenerator<String>- Parameters:
random- for generating the value- Returns:
- generated value, either a null or non-null
-