Module json_values

Class JsStrGen

java.lang.Object
jsonvalues.gen.JsStrGen
All Implemented Interfaces:
fun.gen.Gen<JsStr>, Function<Random,Supplier<JsStr>>

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 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 Type
    Method
    Description
    static fun.gen.Gen<JsStr>
    Generator tha produces an alphabetic character
    static fun.gen.Gen<JsStr>
    alphabetic(int length)
    Generates a string made up of alphabetic characters
    static fun.gen.Gen<JsStr>
    alphabetic(int minLength, int maxLength)
    Generates a string made up of alphabetic characters
    static fun.gen.Gen<JsStr>
    Generator tha produces an alphanumeric character
    static fun.gen.Gen<JsStr>
    alphanumeric(int length)
    Generates a string made up of alphanumeric characters
    static fun.gen.Gen<JsStr>
    alphanumeric(int minLength, int maxLength)
    Generates a string made up of alphanumeric characters
    apply(Random seed)
    Returns a supplier from the specified seed that generates a new JsStr each time it's called
    static fun.gen.Gen<JsStr>
    arbitrary(int length)
    returns a generator that produces arbitrary strings
    static fun.gen.Gen<JsStr>
    arbitrary(int minLength, int maxLength)
    returns a generator that produces arbitrary strings
    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.
    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>
    Generator tha produces a digit from 0 to 9
    static fun.gen.Gen<JsStr>
    digits(int length)
    Generates a string made up of digits
    static fun.gen.Gen<JsStr>
    digits(int minLength, int maxLength)
    Generates a string made up of digits
    static fun.gen.Gen<JsStr>
    Generator tha produces a letter from a to z
    static fun.gen.Gen<JsStr>
    letters(int length)
    Generates a string made up of letters
    static fun.gen.Gen<JsStr>
    letters(int minLength, int maxLength)
    Generates a string made up of letters

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Function

    andThen, compose

    Methods inherited from interface fun.gen.Gen

    map, peek, sample, sample, sample, suchThat, suchThat, then
  • Method Details

    • 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 string
      maxLength - 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 string
      maxLength - 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 string
      maxLength - 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 string
      maxLength - 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
    • apply

      public Supplier<JsStr> apply(Random seed)
      Returns a supplier from the specified seed that generates a new JsStr each time it's called
      Specified by:
      apply in interface Function<Random,Supplier<JsStr>>
      Parameters:
      seed - the generator seed
      Returns:
      a JsStr supplier