- java.lang.Object
-
- org.refcodes.struct.PathComparator
-
- All Implemented Interfaces:
Comparator<String>
public class PathComparator extends Object implements Comparator<String>
Comparator for path elements, it takes care to sort index values correctly, e.g. "1000" must come after "9": The paths "/foo/bar/1000/wow" and "/foo/bar/9/wow" should be sorted as follows:"/foo/bar/9/wow" "/foo/bar/1000/wow"
-
-
Constructor Summary
Constructors Constructor Description PathComparator(char aDelimiter)
Constructs thePathComparator
with the given path delimiter.PathComparator(char aDelimiter, PathSortStrategy aPathSortStrategy)
Constructs thePathComparator
with the given path delimiter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(String o1, String o2)
-
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 Detail
-
PathComparator
public PathComparator(char aDelimiter)
Constructs thePathComparator
with the given path delimiter.- Parameters:
aDelimiter
- The path delimiter to use.
-
PathComparator
public PathComparator(char aDelimiter, PathSortStrategy aPathSortStrategy)
Constructs thePathComparator
with the given path delimiter.- Parameters:
aDelimiter
- The path delimiter to use.aPathSortStrategy
- ThePathSortStrategy
to use for comparisons.
-
-
Method Detail
-
compare
public int compare(String o1, String o2)
- Specified by:
compare
in interfaceComparator<String>
-
-