Package jmri.util

Class NamedBeanComparator<B extends NamedBean>

Type Parameters:
B - supported type of NamedBean
All Implemented Interfaces:
Direct Known Subclasses:

public class NamedBeanComparator<B extends NamedBean>
extends Object
implements 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.