Package jmri.util

Class PreferNumericComparator

  • All Implemented Interfaces:

    public class PreferNumericComparator
    extends AlphanumComparator
    Perform an comparison using AlphanumComparator, followed up with a standard String comparison if, String) returns 0.

    If the requirement is that, 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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(java.lang.String s1, java.lang.String s2)  
      • 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