Class ClassNameComparator
java.lang.Object
edu.nps.moves.dis7.examples.ClassNameComparator
- All Implemented Interfaces:
Comparator<Pdu>
A comparator that is used by the java util classes for sorting. This
sorts members of a collection by class name.
Used like so:
Collections.sort(aList, new ClassNameComparator());
- Author:
- DMcG
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Returns a number less than, equal to, or greater than zero, depending on whether the object is lexically less than, equal to, or greater than the other object.boolean
Returns true if this comparator is the same class as the comparator passed in.int
hashCode()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
ClassNameComparator
public ClassNameComparator()default constructor
-
-
Method Details
-
compare
Returns a number less than, equal to, or greater than zero, depending on whether the object is lexically less than, equal to, or greater than the other object.- Specified by:
compare
in interfaceComparator<Pdu>
- Parameters:
object1
- first object to compareobject2
- second object to compare
-
equals
-
hashCode
-