Package com.google.gerrit.server.util
Class MostSpecificComparator
java.lang.Object
com.google.gerrit.server.util.MostSpecificComparator
- All Implemented Interfaces:
Comparator<AccessSection>
Order the Ref Pattern by the most specific. This sort is done by:
- 1 - The minor value of Levenshtein string distance between the branch name and the regex string shortest example. A shorter distance is a more specific match.
- 2 - Finites first, infinities after.
- 3 - Number of transitions. More transitions is more specific.
- 4 - Length of the expression text.
For example, if given refs/heads/m* and refs/heads/*, the distances are 5 and 6. It means that refs/heads/m* is more specific because it's closer to refs/heads/master than refs/heads/*.
Another example could be refs/heads/* and refs/heads/[a-zA-Z]*, the distances are both 6. Both are infinite, but refs/heads/[a-zA-Z]* has more transitions, which after all turns it more specific.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
int
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
MostSpecificComparator
-
-
Method Details
-
compare
- Specified by:
compare
in interfaceComparator<AccessSection>
-
compare
-