Package jsonvalues.gen
Class JsStrGen
- java.lang.Object
-
- jsonvalues.gen.JsStrGen
-
public final class JsStrGen extends Object implements fun.gen.Gen<JsStr>
Represents a JsStr generator. There are different static factory methods to create all kind of generators: - One character generators likealphanumeric
,digit
,letter
andalphabetic
. - String generators likedigits
,letters
,alphanumeric
,alphabetic
,arbitrary
andbiased
.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static fun.gen.Gen<JsStr>
alphabetic()
Generator tha produces an alphabetic characterstatic 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 charactersstatic fun.gen.Gen<JsStr>
alphanumeric()
Generator tha produces an alphanumeric characterstatic fun.gen.Gen<JsStr>
alphanumeric(int length)
Generates a string made up of alphanumeric charactersstatic fun.gen.Gen<JsStr>
alphanumeric(int minLength, int maxLength)
Generates a string made up of alphanumeric charactersSupplier<JsStr>
apply(Random seed)
Returns a supplier from the specified seed that generates a new JsStr each time it's calledstatic fun.gen.Gen<JsStr>
arbitrary(int length)
returns a generator that produces arbitrary stringsstatic fun.gen.Gen<JsStr>
arbitrary(int minLength, int maxLength)
returns a generator that produces arbitrary stringsstatic fun.gen.Gen<JsStr>
biased(int length)
returns a biased generators 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 generators that produces, with higher probability, potential problematic values that usually cause more bugs.static fun.gen.Gen<JsStr>
digit()
Generator tha produces a digit from 0 to 9static fun.gen.Gen<JsStr>
digits(int length)
Generates a string made up of digitsstatic fun.gen.Gen<JsStr>
digits(int minLength, int maxLength)
Generates a string made up of digitsstatic fun.gen.Gen<JsStr>
letter()
Generator tha produces a letter from a to zstatic fun.gen.Gen<JsStr>
letters(int length)
Generates a string made up of lettersstatic fun.gen.Gen<JsStr>
letters(int minLength, int maxLength)
Generates a string made up of letters
-
-
-
Method Detail
-
digit
public static fun.gen.Gen<JsStr> digit()
Generator tha produces a digit from 0 to 9- Returns:
- a JsStr generator
-
letter
public static fun.gen.Gen<JsStr> letter()
Generator tha produces a letter from a to z- Returns:
- a JsStr generator
-
alphabetic
public static fun.gen.Gen<JsStr> alphabetic()
Generator tha produces an alphabetic character- Returns:
- a JsStr generator
-
alphanumeric
public static fun.gen.Gen<JsStr> alphanumeric()
Generator tha produces an alphanumeric character- Returns:
- a JsStr generator
-
digits
public static fun.gen.Gen<JsStr> digits(int minLength, int maxLength)
Generates a string made up of digits- Parameters:
minLength
- minimum length of the stringmaxLength
- maximum length of the string (inclusive)- Returns:
- a string generator
-
digits
public static fun.gen.Gen<JsStr> digits(int length)
Generates a string made up of digits- Parameters:
length
- the length of the string- Returns:
- a string generator
-
letters
public static fun.gen.Gen<JsStr> letters(int minLength, int maxLength)
Generates a string made up of letters- Parameters:
minLength
- minimum length of the stringmaxLength
- maximum length of the string (inclusive)- Returns:
- a string generator
-
letters
public static fun.gen.Gen<JsStr> letters(int length)
Generates a string made up of letters- Parameters:
length
- length of the string- Returns:
- a string generator
-
alphabetic
public static fun.gen.Gen<JsStr> alphabetic(int minLength, int maxLength)
Generates a string made up of alphabetic characters- Parameters:
minLength
- minimum length of the stringmaxLength
- maximum length of the string (inclusive)- Returns:
- a string generator
-
alphabetic
public static fun.gen.Gen<JsStr> alphabetic(int length)
Generates a string made up of alphabetic characters- Parameters:
length
- length of the string- Returns:
- a string generator
-
alphanumeric
public static fun.gen.Gen<JsStr> alphanumeric(int minLength, int maxLength)
Generates a string made up of alphanumeric characters- Parameters:
minLength
- minimum length of the stringmaxLength
- maximum length of the string (inclusive)- Returns:
- a string generator
-
alphanumeric
public static fun.gen.Gen<JsStr> alphanumeric(int length)
Generates a string made up of alphanumeric characters- Parameters:
length
- length of the string- Returns:
- a string generator
-
arbitrary
public static fun.gen.Gen<JsStr> arbitrary(int minLength, int maxLength)
returns a generator that produces arbitrary strings- Parameters:
minLength
- minimum length of the string (inclusive)maxLength
- maximum length of the string (inclusive)- Returns:
- a string generator
-
arbitrary
public static fun.gen.Gen<JsStr> arbitrary(int length)
returns a generator that produces arbitrary strings- Parameters:
length
- of the string- Returns:
- a string generator
-
biased
public static fun.gen.Gen<JsStr> biased(int minLength, int maxLength)
returns a biased generators that produces, with higher probability, potential problematic values that usually cause more bugs. These values are:- empty string (if minLength is equal to zero) - blank string of length minLength - blank string of length maxLength - arbitrary string of length minLength - arbitrary string of length maxLength
- Parameters:
minLength
- minimum length of the string (inclusive)maxLength
- maximum length of the string (inclusive)- Returns:
- a string generator
-
biased
public static fun.gen.Gen<JsStr> biased(int length)
returns a biased generators that produces, with higher probability, potential problematic values that usually cause more bugs. These values are:- blank string
- Parameters:
length
- minimum length of the string (inclusive)- Returns:
- a string generator
-
-