- java.lang.Object
-
- jmri.util.NamedBeanComparator<B>
-
- 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.
-
-
Constructor Summary
Constructors Constructor Description NamedBeanComparator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(B n1, B n2)
-