KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > annotations > TicketComparator


1 //$Id: TicketComparator.java,v 1.1 2005/05/16 14:57:03 epbernard Exp $
2
package org.hibernate.test.annotations;
3
4 import java.util.Comparator JavaDoc;
5
6 /**
7  * Ticket comparator ordering longest first
8  *
9  * @author Emmanuel Bernard
10  */

11 public class TicketComparator implements Comparator JavaDoc<Ticket> {
12
13     public int compare(Ticket ticket, Ticket ticket1) {
14         if (ticket == null || ticket1 == null) {
15             throw new IllegalStateException JavaDoc("Ticket comparison only available through non null tickets");
16         }
17         return ticket1.getNumber().length() - ticket.getNumber().length();
18
19     }
20 }
21
Popular Tags