Interface StringArbitrary

  • All Superinterfaces:
    Arbitrary<java.lang.String>

    @API(status=MAINTAINED,
         since="1.0")
    public interface StringArbitrary
    extends Arbitrary<java.lang.String>
    Fluent interface to configure arbitraries that generate String values.
    • Method Detail

      • ofMaxLength

        StringArbitrary ofMaxLength​(int maxLength)
        Set the maximum allowed length maxLength (included) of generated strings.
        Throws:
        java.lang.IllegalArgumentException - if maxLength < 0 or maxLength < min length
      • ofMinLength

        StringArbitrary ofMinLength​(int minLength)
        Set the minimum allowed length minLength (included) of generated strings. This will also set the max length of the string if minLength is larger than the current max length.
        Throws:
        java.lang.IllegalArgumentException - if minLength < 0
      • ofLength

        default StringArbitrary ofLength​(int length)
        Fix the length to length of generated strings.
        Throws:
        java.lang.IllegalArgumentException - if length < 0
      • withChars

        StringArbitrary withChars​(char... chars)
        Allow all chars in chars to show up in generated strings. Can be combined with other methods that allow chars.
      • withChars

        @API(status=MAINTAINED,
             since="1.2.1")
        StringArbitrary withChars​(java.lang.CharSequence chars)
        Allow all chars in chars to show up in generated strings. Can be combined with other methods that allow chars.
      • withCharRange

        StringArbitrary withCharRange​(char from,
                                      char to)
        Allow all chars within from (included) and to (included) to show up in generated strings. Can be combined with other methods that allow chars.
      • ascii

        StringArbitrary ascii()
        Allow all ascii chars to show up in generated strings. Can be combined with other methods that allow chars.
      • alpha

        StringArbitrary alpha()
        Allow all alpha chars to show up in generated strings. Can be combined with other methods that allow chars.
      • numeric

        StringArbitrary numeric()
        Allow all numeric chars (digits) to show up in generated strings. Can be combined with other methods that allow chars.
      • whitespace

        StringArbitrary whitespace()
        Allow all chars that will return true for Character.isWhitespace(char). Can be combined with other methods that allow chars.
      • all

        StringArbitrary all()
        Allow all unicode chars even noncharacters and private use characters but only in plane 0 (aka Basic Multilingual Plane)
      • excludeChars

        @API(status=MAINTAINED,
             since="1.5.1")
        StringArbitrary excludeChars​(char... charsToExclude)
        Exclude all charsToExclude from generated strings
        Parameters:
        charsToExclude - chars to exclude
        Returns:
        new instance of arbitrary
      • withLengthDistribution

        @API(status=EXPERIMENTAL,
             since="1.5.3")
        StringArbitrary withLengthDistribution​(RandomDistribution lengthDistribution)
        Set random distribution distribution of length of generated string. The distribution's center is the minimum length of the generated list.
      • repeatChars

        @API(status=EXPERIMENTAL,
             since="1.5.3")
        Arbitrary<java.lang.String> repeatChars​(double repeatProbability)
        Set the probability for repeating chars within the string.
        Parameters:
        repeatProbability - Must be between 0 (included) and 1 (excluded)