Class DefaultComparableNamed<N extends java.lang.Comparable<N>>

  • All Implemented Interfaces:
    Named<N>, java.lang.Comparable<Named<N>>
    Direct Known Subclasses:
    DefaultComparableIDNamed, Host

    public class DefaultComparableNamed<N extends java.lang.Comparable<N>>
    extends DefaultNamed<N>
    implements java.lang.Comparable<Named<N>>
    A default implementation of a named object comparable by name. This implementation does not allow a null name.
    Author:
    Garret Wilson
    • Constructor Detail

      • DefaultComparableNamed

        public DefaultComparableNamed​(N newName)
        Constructor specifying the name.
        Parameters:
        newName - The object's new name.
        Throws:
        java.lang.NullPointerException - if the given name is null;
    • Method Detail

      • compareTo

        public int compareTo​(Named<N> namedObject)
                      throws java.lang.ClassCastException
        Compares this object to another object. This method determines order based upon the name.
        Specified by:
        compareTo in interface java.lang.Comparable<N extends java.lang.Comparable<N>>
        Parameters:
        namedObject - The object with which to compare this object.
        Returns:
        A negative integer, zero, or a positive integer as this name is less than, equal to, or greater than the name of the specified object, respectively.
        Throws:
        java.lang.ClassCastException
        See Also:
        DefaultNamed.getName()