java.lang.Object
jsonvalues.gen.JsStrGen
Represents a JsStr generator. There are different static factory methods to create all kinds of generators:
- One character generators like
alphanumeric
, digit
, letter
, and alphabetic
.
- String generators like digits
, letters
, alphanumeric
, alphabetic
, arbitrary
, and biased
.
The length of the generated strings is distributed uniformly over a specified interval.
The biased generator produces, with higher probability, potential problematic values that usually cause more bugs (empty and blank strings, for example).
If none of the previous factory methods suit your needs, you can still create a JsStr generator from a string generator and the function map:
import fun.gen.Gen;
import jsonvalues.JsStr;
Gen<String> strGen = seed -> () -> {...};
Gen<JsStr> jsStrGen = gen.map(JsStr::of);
-
Method Summary
Modifier and TypeMethodDescriptionstatic fun.gen.Gen<JsStr>
Returns a generator that produces a single alphabetic character.static fun.gen.Gen<JsStr>
alphabetic
(int length) Generates a string made up of alphabetic charactersstatic fun.gen.Gen<JsStr>
alphabetic
(int minLength, int maxLength) Generates a string made up of alphabetic characters with a length betweenminLength
andmaxLength
.static fun.gen.Gen<JsStr>
Returns a generator that produces a single alphanumeric character.static fun.gen.Gen<JsStr>
alphanumeric
(int length) Generates a string made up of alphanumeric characters with a length oflength
.static fun.gen.Gen<JsStr>
alphanumeric
(int minLength, int maxLength) Generates a string made up of alphanumeric characters with a length betweenminLength
andmaxLength
.static fun.gen.Gen<JsStr>
arbitrary
(int length) Returns a generator that produces arbitrary strings with a length oflength
.static fun.gen.Gen<JsStr>
arbitrary
(int minLength, int maxLength) Returns a generator that produces arbitrary strings with a length betweenminLength
andmaxLength
.static fun.gen.Gen<JsStr>
ascii()
Returns a generator that produces a single ASCII character.static fun.gen.Gen<JsStr>
ascii
(int length) Generates a string made up of alphabetic characters with a length oflength
.static fun.gen.Gen<JsStr>
ascii
(int minLength, int maxLength) Generates a string made up of ASCII characters with a length betweenminLength
andmaxLength
.static fun.gen.Gen<JsStr>
biased
(int length) Returns a biased generator that produces, with higher probability, potential problematic values that usually cause more bugs.static fun.gen.Gen<JsStr>
biased
(int minLength, int maxLength) Returns a biased generator that produces, with higher probability, potential problematic values that usually cause more bugs.static fun.gen.Gen<JsStr>
digit()
Returns a generator that produces a single digit from 0 to 9.static fun.gen.Gen<JsStr>
digits
(int length) Generates a string made up of digits with a length oflength
.static fun.gen.Gen<JsStr>
digits
(int minLength, int maxLength) Generates a string made up of digits with a length betweenminLength
andmaxLength
.static fun.gen.Gen<JsStr>
letter()
Returns a generator that produces a single letter from 'a' to 'z'.static fun.gen.Gen<JsStr>
letters
(int length) Generates a string made up of letters with a length oflength
.static fun.gen.Gen<JsStr>
letters
(int minLength, int maxLength) Generates a string made up of letters with a length betweenminLength
andmaxLength
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface fun.gen.Gen
classify, classify, collect, collect, distinct, distinct, map, peek, sample, sample, sample, suchThat, suchThat, then
-
Method Details
-
digit
Returns a generator that produces a single digit from 0 to 9.- Returns:
- A JsStr generator.
-
letter
Returns a generator that produces a single letter from 'a' to 'z'.- Returns:
- A JsStr generator.
-
alphabetic
Returns a generator that produces a single alphabetic character.- Returns:
- A JsStr generator.
-
ascii
Returns a generator that produces a single ASCII character.- Returns:
- A JsStr generator.
-
alphanumeric
Returns a generator that produces a single alphanumeric character.- Returns:
- A JsStr generator.
-
digits
Generates a string made up of digits with a length betweenminLength
andmaxLength
.- Parameters:
minLength
- Minimum length of the string (inclusive).maxLength
- Maximum length of the string (inclusive).- Returns:
- A string generator.
-
digits
Generates a string made up of digits with a length oflength
.- Parameters:
length
- Length of the string.- Returns:
- A string generator.
-
letters
Generates a string made up of letters with a length betweenminLength
andmaxLength
.- Parameters:
minLength
- Minimum length of the string (inclusive).maxLength
- Maximum length of the string (inclusive).- Returns:
- A string generator.
-
letters
Generates a string made up of letters with a length oflength
.- Parameters:
length
- Length of the string.- Returns:
- A string generator.
-
alphabetic
Generates a string made up of alphabetic characters with a length betweenminLength
andmaxLength
.- Parameters:
minLength
- Minimum length of the string (inclusive).maxLength
- Maximum length of the string (inclusive).- Returns:
- A string generator.
-
ascii
Generates a string made up of ASCII characters with a length betweenminLength
andmaxLength
.- Parameters:
minLength
- Minimum length of the string (inclusive).maxLength
- Maximum length of the string (inclusive).- Returns:
- A string generator.
-
alphabetic
Generates a string made up of alphabetic characters- Parameters:
length
- length of the string- Returns:
- a string generator
-
ascii
Generates a string made up of alphabetic characters with a length oflength
.- Parameters:
length
- Length of the string.- Returns:
- A string generator.
-
alphanumeric
Generates a string made up of alphanumeric characters with a length betweenminLength
andmaxLength
.- Parameters:
minLength
- Minimum length of the string (inclusive).maxLength
- Maximum length of the string (inclusive).- Returns:
- A string generator.
-
alphanumeric
Generates a string made up of alphanumeric characters with a length oflength
.- Parameters:
length
- Length of the string.- Returns:
- A string generator.
-
arbitrary
Returns a generator that produces arbitrary strings with a length betweenminLength
andmaxLength
.- Parameters:
minLength
- Minimum length of the string (inclusive).maxLength
- Maximum length of the string (inclusive).- Returns:
- A string generator.
-
arbitrary
Returns a generator that produces arbitrary strings with a length oflength
.- Parameters:
length
- Length of the string.- Returns:
- A string generator.
-
biased
Returns a biased generator that produces, with higher probability, potential problematic values that usually cause more bugs. These values include empty strings (ifminLength
is equal to zero), blank strings of lengthminLength
, blank strings of lengthmaxLength
, arbitrary strings of lengthminLength
, and arbitrary strings of lengthmaxLength
.- Parameters:
minLength
- Minimum length of the string (inclusive).maxLength
- Maximum length of the string (inclusive).- Returns:
- A string generator.
-
biased
Returns a biased generator that produces, with higher probability, potential problematic values that usually cause more bugs. These values include blank strings.- Parameters:
length
- Minimum length of the string (inclusive).- Returns:
- A string generator.
-
apply
-