Interface StringMatcher

  • All Superinterfaces:
    java.util.function.Predicate<java.lang.String>

    public interface StringMatcher
    extends java.util.function.Predicate<java.lang.String>
    An interface for allowing direct string matching or regular expressions. Use the static factory string(String) or regex(String) to instantiate the appropriate matcher. Custom implementations should override Object.toString() for better error reporting.
    • Method Summary

      Static Methods 
      Modifier and Type Method Description
      static StringMatcher regex​(java.lang.String string)
      Create a matcher using regular expressions.
      static StringMatcher string​(java.lang.String string)
      Create a matcher for string equality.
      • Methods inherited from interface java.util.function.Predicate

        and, negate, or, test
    • Method Detail

      • string

        static StringMatcher string​(java.lang.String string)
        Create a matcher for string equality.
      • regex

        static StringMatcher regex​(java.lang.String string)
                            throws RegexSyntaxException
        Create a matcher using regular expressions. Regex matching ignores null values and returns false instead of erroring.
        Parameters:
        string - the input pattern
        Returns:
        a regex based instance
        Throws:
        RegexSyntaxException - if the input pattern is not valid regex. This is a runtime exception and probably should be handled