View Javadoc

1   package com.atlassian.plugin.predicate;
2   
3   import java.util.Collection;
4   import java.util.regex.Pattern;
5   
6   import com.atlassian.annotations.ExperimentalApi;
7   import com.atlassian.plugin.Plugin;
8   import com.atlassian.plugin.util.RegularExpressions;
9   
10  /**
11   * A plugin predicate which matches plugins whose key *does not* match one of a given list of
12   * excluded regular expressions.
13   */
14  @ExperimentalApi
15  public class PluginKeyExcludePatternsPredicate implements PluginPredicate
16  {
17      Pattern pattern;
18  
19      public PluginKeyExcludePatternsPredicate(final Collection<String> excluded)
20      {
21          this.pattern = Pattern.compile(RegularExpressions.anyOf(excluded));
22      }
23  
24      public boolean matches(final Plugin plugin)
25      {
26          // We do not match if the exclusions do match
27          return !pattern.matcher(plugin.getKey()).matches();
28      }
29  }