Class PackageNameMatcher


  • public class PackageNameMatcher
    extends java.lang.Object
    An utility class for filtering package names.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String description  
      private java.util.List<java.util.regex.Pattern> patterns  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PackageNameMatcher​(java.util.List<java.util.regex.Pattern> patterns)
      Constructs a new object which matches against the given patterns.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String buildDescription()  
      private static java.util.regex.Pattern buildPattern​(java.lang.String spec)  
      static PackageNameMatcher compile​(java.util.List<java.lang.String> specs)
      Compiles the given list of package name specification strings into a matching object.
      boolean matches​(java.lang.String packageName)
      Returns true if the given package name matches against any of the patterns in this matcher.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • patterns

        private final java.util.List<java.util.regex.Pattern> patterns
      • description

        private final java.lang.String description
    • Constructor Detail

      • PackageNameMatcher

        private PackageNameMatcher​(java.util.List<java.util.regex.Pattern> patterns)
        Constructs a new object which matches against the given patterns.
        Parameters:
        patterns -
    • Method Detail

      • compile

        public static PackageNameMatcher compile​(java.util.List<java.lang.String> specs)
        Compiles the given list of package name specification strings into a matching object.

        If the list is empty, the resulting object will never match any package name, which means that matches(String) will always return false.

        Parameters:
        specs - The list of package name specifications. For details on specification syntax see #compile(String).
        Returns:
        A new matching object.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the given argument is null or if any of the strings in the list is an invalid package name specification.
      • buildPattern

        private static java.util.regex.Pattern buildPattern​(java.lang.String spec)
      • buildDescription

        private java.lang.String buildDescription()
      • matches

        public boolean matches​(java.lang.String packageName)
        Returns true if the given package name matches against any of the patterns in this matcher.
        Returns:
        Always false if the given package name is null or an empty string.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object