Package jmri.util

Class NamedBeanComparator<B extends NamedBean>

  • Type Parameters:
    B - supported type of NamedBean
    All Implemented Interfaces:
    java.util.Comparator<B>
    Direct Known Subclasses:
    NamedBeanPreferNumericComparator

    public class NamedBeanComparator<B extends NamedBean>
    extends java.lang.Object
    implements java.util.Comparator<B>
    Comparator for JMRI NamedBeans via their System Names.

    Uses the built-in Comparable interface of the named beans.

    A System Name is a system prefix followed by type letter then a suffix with a system-specific format. This class first compares on prefix, then if the prefixes are equal it compares the type letter, then if they're still equal it does an AlphanumComparator compare on suffix.

    This sorts on the information in the NamedBean itself, including using the actual type by deferring prefix comparison into the specific NamedBean subclass. This is different from the (deprecated) SystemNameComparator, which only does a common lexical sort. See the Names documentation page.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(B n1, B n2)  
      • 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