Package jmri.util
Class PreferNumericComparator
java.lang.Object
jmri.util.AlphanumComparator
jmri.util.PreferNumericComparator
- All Implemented Interfaces:
Comparator<String>
Perform an comparison using
AlphanumComparator, followed up with a
standard String comparison if
AlphanumComparator.compare(String, String) returns 0.
If the requirement is that Comparator.compare(Object, Object) return
0 for two numerically identical Strings (i.e. 42 == 0042), use
AlphanumComparator, but if the requirement is that Strings should be
numerically ordered, but that non-identical representations should be
different, (i.e. 42 != 0042, but order should be
3, 4, 5, 42, 0042, 50), use this Comparator, since the standard
String comparator will not order numbers correctly.
-
Field Summary
Fields inherited from class jmri.util.AlphanumComparator
skip -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
PreferNumericComparator
public PreferNumericComparator()
-
-
Method Details
-
compare
- Specified by:
comparein interfaceComparator<String>- Overrides:
comparein classAlphanumComparator
-