Class Person.CompareByZip

java.lang.Object
  extended byPerson.CompareByZip
All Implemented Interfaces:
java.util.Comparator
Enclosing class:
Person

public static class Person.CompareByZip
extends java.lang.Object
implements java.util.Comparator

Comparator for comparing two persons by order of zip code


Constructor Summary
Person.CompareByZip()
           
 
Method Summary
 int compare(java.lang.Object person1, java.lang.Object person2)
          Compare two objects (which must both be Persons) by zip
 boolean equals(java.lang.Object person1, java.lang.Object person2)
          Compare two objects (which must both be Persons) by zip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

Person.CompareByZip

public Person.CompareByZip()
Method Detail

compare

public int compare(java.lang.Object person1,
                   java.lang.Object person2)
Compare two objects (which must both be Persons) by zip

Specified by:
compare in interface java.util.Comparator
Parameters:
person1 - the first object
person2 - the second object
Returns:
a negative number if person1 belongs before person2 in order of zip; 0 if they are equal; a positive number if person1 belongs after person2
Throws:
java.lang.ClassCastException - if either parameter is not a Person object

equals

public boolean equals(java.lang.Object person1,
                      java.lang.Object person2)
Compare two objects (which must both be Persons) by zip

Parameters:
person1 - the first object
person2 - the second object
Returns:
true if they have the same zip, false if they do not
Throws:
java.lang.ClassCastException - if either parameter is not a Person object