Class RegexPatterns

java.lang.Object
org.opendaylight.yangtools.binding.contract.RegexPatterns

public final class RegexPatterns extends Object
  • Method Details

    • isNegatedPattern

      public static boolean isNegatedPattern(Pattern pattern)
      Check if the specified Pattern is the result of negatePatternString(String). This method assumes the pattern was not hand-coded but rather was automatically-generated, such that its non-automated parts come from XSD regular expressions. If this constraint is violated, this method may result false positives.
      Parameters:
      pattern - Pattern to check
      Returns:
      True if this pattern is a negation.
      Throws:
      NullPointerException - if pattern is null
      IllegalArgumentException - if the pattern does not conform to expected structure
    • negatePatternString

      public static String negatePatternString(String pattern)
      Create a Pattern expression which performs inverted match to the specified pattern. The input pattern is expected to be a valid regular expression passing Pattern.compile(String) and to have both start and end of string anchors as the first and last characters.
      Parameters:
      pattern - Pattern regular expression to negate
      Returns:
      Negated regular expression
      Throws:
      IllegalArgumentException - if the pattern does not conform to expected structure
      NullPointerException - if pattern is null