Class ClassNameComparator

java.lang.Object
edu.nps.moves.dis7.examples.ClassNameComparator
All Implemented Interfaces:
Comparator<Pdu>

public class ClassNameComparator extends Object implements 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 Details

    • ClassNameComparator

      public ClassNameComparator()
      default constructor
  • Method Details

    • compare

      public int compare(Pdu object1, Pdu object2)
      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 interface Comparator<Pdu>
      Parameters:
      object1 - first object to compare
      object2 - second object to compare
    • equals

      public boolean equals(Object obj)
      Returns true if this comparator is the same class as the comparator passed in.
      Specified by:
      equals in interface Comparator<Pdu>
      Overrides:
      equals in class Object
      Parameters:
      obj - object to compare to this object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object