Class StringRandomizers

java.lang.Object
io.github.cjstehno.testthings.rando.StringRandomizers

public final class StringRandomizers extends Object
A collection of randomizers for generating strings.
  • Field Details

  • Constructor Details

    • StringRandomizers

      public StringRandomizers()
  • Method Details

    • oneFrom

      public static Randomizer<String> oneFrom(String string)
      Selects a random value from the characters of the given string.
      Parameters:
      string - the string of values
      Returns:
      the randomizer
    • letter

      public static Randomizer<String> letter()
      Generates a random letter (upper or lower case).
      Returns:
      the randomizer
    • number

      public static Randomizer<String> number()
      Generates a random number string (one number).
      Returns:
      the randomizer
    • alphabetic

      public static Randomizer<String> alphabetic(Randomizer<Integer> countRando)
      Generates a random alphabetic string (upper and lower case).
      Parameters:
      countRando - the randomizer used to determine the length of the string
      Returns:
      the randomizer
    • numeric

      public static Randomizer<String> numeric(Randomizer<Integer> countRando)
      Generates a random numeric string (with multiple digits).
      Parameters:
      countRando - the randomizer used to determine the length of the string
      Returns:
      the randomizer
    • alphanumeric

      public static Randomizer<String> alphanumeric(Randomizer<Integer> countRando)
      Generates a random alphanumeric string (upper and lower case).
      Parameters:
      countRando - the randomizer used to determine the length of the string
      Returns:
      the randomizer
    • words

      public static Randomizer<String[]> words(Randomizer<Integer> countRando, Randomizer<Integer> wordSizeRando)
      Generates multiple alphabetic strings of random size, returned as an array of words.
      Parameters:
      countRando - the randomizer used to determine the number of words
      wordSizeRando - the randomizer used to determine the size of each word
      Returns:
      the randomizer
    • wordFrom

      public static Randomizer<String> wordFrom(String sentence)
      Randomly selects a word from the provided sentence (words are delimited by spaces).
      Parameters:
      sentence - the sentence
      Returns:
      the randomizer
    • wordFrom

      public static Randomizer<String> wordFrom(String[] words)
      Randomly selects a word from the provided words.
      Parameters:
      words - the available words
      Returns:
      the randomizer
    • aChar

      public static Randomizer<Character> aChar()
      Randomly generates a character (letters only).
      Returns:
      the randomizer
    • charArray

      public static Randomizer<char[]> charArray(Randomizer<Integer> countRando)
      Randomly generates a character array of random length.
      Parameters:
      countRando - the randomizer used to determine the length of the array
      Returns:
      the randomizer