Class RgxGen

java.lang.Object
com.github.curiousoddman.rgxgen.RgxGen

public class RgxGen extends Object
String values generator based on regular expression pattern
  • Method Details

    • forPattern

      public static RgxGenBuilder forPattern(String pattern)
    • parse

      public static RgxGen parse(String pattern)
      Parse pattern using DefaultTreeBuilder.
      Parameters:
      pattern - regex pattern for values generation
    • parse

      public static RgxGen parse(RgxGenProperties rgxGenProperties, String pattern)
      Set properties to be used in parsing and generation.
      Parameters:
      rgxGenProperties - configuration properties.
      pattern - regex pattern for values generation
      See Also:
    • getUniqueEstimation

      public Optional<BigInteger> getUniqueEstimation()
      Returns estimation of unique values that can be generated with the pattern.
      Returns:
      number of unique values or null, if infinite
      API Note:
      This might not be accurate! For example the pattern "(a{0,2}|b{0,2})" will estimate to 6, though actual count is only 5, because right and left part of group can yield same value
    • stream

      public Stream<String> stream()
      Creates infinite stream of randomly generated values.
      Returns:
      stream of randomly generated strings
      See Also:
    • iterateUnique

      public StringIterator iterateUnique()
      Creates iterator over unique values.
      Returns:
      Iterator over unique values
    • generate

      public String generate()
      Generate random string from the pattern.
      Returns:
      matching random string
    • generate

      public String generate(RandomGenerator random)
      Generate random string from the pattern. Random initialized with same seed will produce same results.
      Parameters:
      random - random to use for the generation.
      Returns:
      generated string.
    • generateNotMatching

      public String generateNotMatching()
      Generate random string that does not match a pattern.
      Returns:
      not matching random string.
    • generateNotMatching

      public String generateNotMatching(RandomGenerator random)
      Generate random string that does not match a pattern. Random initialized with same seed will produce same results.
      Parameters:
      random - random to use for the generation.
      Returns:
      generated string.
    • visit

      public void visit(NodeVisitor customVisitor)