]> source.dussan.org Git - jgit.git/commitdiff
Add varargs version of PathFilterGroup.createFromStrings 09/4309/4
authorKevin Sawicki <kevin@github.com>
Thu, 29 Sep 2011 17:16:29 +0000 (10:16 -0700)
committerChris Aniszczyk <zx@twitter.com>
Fri, 30 Sep 2011 22:00:53 +0000 (15:00 -0700)
This allows the following usage pattern:

  PathFilterGroup.createFromStrings("path1", "path2");

Change-Id: I589e758cc55873ce75614602e017ac793435e24d
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java

index 756b000684a5596e4d2a6db1d581a0e8b497a822..27b1b1044fc2a32ec02328ddbcf6f48d2d644e0d 100644 (file)
@@ -91,6 +91,33 @@ public class PathFilterGroup {
                return create(p);
        }
 
+       /**
+        * Create a collection of path filters from Java strings.
+        * <p>
+        * Path strings are relative to the root of the repository. If the user's
+        * input should be assumed relative to a subdirectory of the repository the
+        * caller must prepend the subdirectory's path prior to creating the filter.
+        * <p>
+        * Path strings use '/' to delimit directories on all platforms.
+        * <p>
+        * Paths may appear in any order. Sorting may be done internally when the
+        * group is constructed if doing so will improve path matching performance.
+        *
+        * @param paths
+        *            the paths to test against. Must have at least one entry.
+        * @return a new filter for the paths supplied.
+        */
+       public static TreeFilter createFromStrings(final String... paths) {
+               if (paths.length == 0)
+                       throw new IllegalArgumentException(
+                                       JGitText.get().atLeastOnePathIsRequired);
+               final int length = paths.length;
+               final PathFilter[] p = new PathFilter[length];
+               for (int i = 0; i < length; i++)
+                       p[i] = PathFilter.create(paths[i]);
+               return create(p);
+       }
+
        /**
         * Create a collection of path filters.
         * <p>