Dedicated specificity comparator in PathPattern

The PathPattern compareTo method is now consistent with equals when
two patterns are of the same specificity but otherwise different.

Separately PathPattern now exposes a Comparator by specificity that
offers the current functionality of compareTo. This can be used for
actual sorting where we only care about specificity.
This commit is contained in:
Rossen Stoyanchev
2017-08-02 18:11:36 +02:00
parent 62fa20fd6f
commit 08dfce2cb5
7 changed files with 58 additions and 48 deletions

View File

@@ -387,7 +387,7 @@ public class PathPatternParserTests {
// Based purely on catchAll
p1 = parse("{*foobar}");
p2 = parse("{*goo}");
assertEquals(0, p1.compareTo(p2));
assertTrue(p1.compareTo(p2) != 0);
p1 = parse("/{*foobar}");
p2 = parse("/abc/{*ww}");