Class DefaultComparableNamed<N extends Comparable<N>>

java.lang.Object
com.globalmentor.model.DefaultNamed<N>
com.globalmentor.model.DefaultComparableNamed<N>
All Implemented Interfaces:
Named<N>, Comparable<Named<N>>
Direct Known Subclasses:
DefaultComparableIDNamed, Host

public class DefaultComparableNamed<N extends Comparable<N>> extends DefaultNamed<N> implements 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 Details

    • DefaultComparableNamed

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

    • compareTo

      public int compareTo(Named<N> namedObject) throws ClassCastException
      Compares this object to another object. This method determines order based upon the name.
      Specified by:
      compareTo in interface Comparable<N extends 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:
      ClassCastException
      See Also: