Class RegexRuleSet

java.lang.Object
com.netflix.genie.common.internal.util.RegexRuleSet

public final class RegexRuleSet extends Object
Utility class to match a string against an ordered set of regexes and obtain an accept/reject response.
Since:
4.0.0
  • Method Details

    • buildWhitelist

      public static RegexRuleSet buildWhitelist(String... patternStrings)
      Factory method to build a whitelist ruleset. (Whitelist rejects everything except for the given patterns).
      Parameters:
      patternStrings - a set of pattern strings that constitute the whitelist
      Returns:
      the ruleset
    • buildWhitelist

      public static RegexRuleSet buildWhitelist(Pattern... patterns)
      Factory method to build a whitelist ruleset. (Whitelist rejects everything except for the given patterns).
      Parameters:
      patterns - a set of patterns that constitute the whitelist
      Returns:
      the ruleset
    • buildBlacklist

      public static RegexRuleSet buildBlacklist(String... patternStrings)
      Factory method to build a whitelist ruleset. (Blacklist accepts everything except for the given patterns).
      Parameters:
      patternStrings - a set of pattern strings that constitute the blacklist
      Returns:
      the ruleset
    • buildBlacklist

      public static RegexRuleSet buildBlacklist(Pattern... patterns)
      Factory method to build a whitelist ruleset. (Blacklist accepts everything except for the given patterns).
      Parameters:
      patterns - a set of patterns that constitute the blacklist
      Returns:
      the ruleset
    • evaluate

      public RegexRuleSet.Response evaluate(String input)
      Evaluate an input string against the rule set.
      Parameters:
      input - an input string
      Returns:
      a response
    • accept

      public boolean accept(String input)
      Evaluate an input string against the ruleset for acceptance.
      Parameters:
      input - an input string
      Returns:
      true if the response for this input is ACCEPT, false otherwise
    • reject

      public boolean reject(String input)
      Evaluate an input string against the ruleset for rejection.
      Parameters:
      input - an input string
      Returns:
      true if the response for this input is REJECT, false otherwise