001package jmri.util;
002
003import java.util.Comparator;
004
005import jmri.*;
006
007/**
008 * Comparator for JMRI NamedBeanHandle of NamedBeans via their System Names.
009 * <p>
010 * Uses the built-in Comparable interface of the named beans.
011 * <p>
012 * Note that unlike the NamedBean itself, the sytem name of a NamedBean within
013 * a particular NamedBeanHandle is <u>not</u> immutable. The handle can point
014 * at a different NamedBean after a rename operation.
015 *
016 * @param <H> NamedBeanHandle of a supported type of NamedBean
017 *
018 * @see NamedBean
019 * @see NamedBeanHandle
020 * @see NamedBeanHandleManager
021 *
022 */
023public class NamedBeanHandleComparator<H extends NamedBeanHandle<? extends NamedBean>>
024                            implements Comparator<H> {
025
026    @Override
027    public int compare(H n1, H n2) {
028        return n1.getBean().compareTo(n2.getBean());
029    }
030}