Class JsStrGen

java.lang.Object
jsonvalues.gen.JsStrGen
All Implemented Interfaces:
fun.gen.Gen<JsStr>, Function<RandomGenerator,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 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 Type
    Method
    Description
    static 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 characters
    static fun.gen.Gen<JsStr>
    alphabetic(int minLength, int maxLength)
    Generates a string made up of alphabetic characters with a length between minLength and maxLength.
    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 of length.
    static fun.gen.Gen<JsStr>
    alphanumeric(int minLength, int maxLength)
    Generates a string made up of alphanumeric characters with a length between minLength and maxLength.
     
    static fun.gen.Gen<JsStr>
    arbitrary(int length)
    Returns a generator that produces arbitrary strings with a length of length.
    static fun.gen.Gen<JsStr>
    arbitrary(int minLength, int maxLength)
    Returns a generator that produces arbitrary strings with a length between minLength and maxLength.
    static fun.gen.Gen<JsStr>
    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 of length.
    static fun.gen.Gen<JsStr>
    ascii(int minLength, int maxLength)
    Generates a string made up of ASCII characters with a length between minLength and maxLength.
    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>
    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 of length.
    static fun.gen.Gen<JsStr>
    digits(int minLength, int maxLength)
    Generates a string made up of digits with a length between minLength and maxLength.
    static fun.gen.Gen<JsStr>
    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 of length.
    static fun.gen.Gen<JsStr>
    letters(int minLength, int maxLength)
    Generates a string made up of letters with a length between minLength and maxLength.

    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

    classify, classify, collect, collect, distinct, distinct, map, peek, sample, sample, sample, suchThat, suchThat, then
  • Method Details

    • digit

      public static fun.gen.Gen<JsStr> digit()
      Returns a generator that produces a single digit from 0 to 9.
      Returns:
      A JsStr generator.
    • letter

      public static fun.gen.Gen<JsStr> letter()
      Returns a generator that produces a single letter from 'a' to 'z'.
      Returns:
      A JsStr generator.
    • alphabetic

      public static fun.gen.Gen<JsStr> alphabetic()
      Returns a generator that produces a single alphabetic character.
      Returns:
      A JsStr generator.
    • ascii

      public static fun.gen.Gen<JsStr> ascii()
      Returns a generator that produces a single ASCII character.
      Returns:
      A JsStr generator.
    • alphanumeric

      public static fun.gen.Gen<JsStr> alphanumeric()
      Returns a generator that produces a single 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 with a length between minLength and maxLength.
      Parameters:
      minLength - Minimum length of the string (inclusive).
      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 with a length of length.
      Parameters:
      length - 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 with a length between minLength and maxLength.
      Parameters:
      minLength - Minimum length of the string (inclusive).
      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 with a length of length.
      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 with a length between minLength and maxLength.
      Parameters:
      minLength - Minimum length of the string (inclusive).
      maxLength - Maximum length of the string (inclusive).
      Returns:
      A string generator.
    • ascii

      public static fun.gen.Gen<JsStr> ascii(int minLength, int maxLength)
      Generates a string made up of ASCII characters with a length between minLength and maxLength.
      Parameters:
      minLength - Minimum length of the string (inclusive).
      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
    • ascii

      public static fun.gen.Gen<JsStr> ascii(int length)
      Generates a string made up of alphabetic characters with a length of length.
      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 with a length between minLength and maxLength.
      Parameters:
      minLength - Minimum length of the string (inclusive).
      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 with a length of length.
      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 with a length between minLength and maxLength.
      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 with a length of length.
      Parameters:
      length - Length of the string.
      Returns:
      A string generator.
    • biased

      public 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. These values include empty strings (if minLength is equal to zero), blank strings of length minLength, blank strings of length maxLength, arbitrary strings of length minLength, and arbitrary strings 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 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

      public Supplier<JsStr> apply(RandomGenerator seed)
      Specified by:
      apply in interface Function<RandomGenerator,Supplier<JsStr>>