Monday, October 21, 2013

Re: Unusual (for me) GWT compile messages

My Comparators all look something like:

class ReservationComparator implements Comparator<Reservation> {
@Override
public int compare(Reservation o1, Reservation o2) {
return Integer.compare(o1.getReservationID(), o2.getReservationID());
}
}

Where  Reservation.getReservationID() returns a simple "int" or 

class BookingIDComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
return Integer.compare(Integer.parseInt(o1), Integer.parseInt(o2));
}
}

Where I am comparing stringified ints.  Actually the third instance is more complex because the sorting criteria of the list-of-object looks at dates and then ints.

class BookingComparator implements Comparator<Booking> {
@Override
public int compare(Booking o1, Booking o2) {
int result = 0;
if ((result = o1.getTimeBookingStart().compareTo(
o2.getTimeBookingStart())) == 0) {
if ((result = o1.getTimeBookingEnd().compareTo(
o2.getTimeBookingEnd())) == 0) {
result = Integer.compare(o1.getBookingID(),
o2.getBookingID());
}
}
return result;
}
}

that is Date.compare, Date.compare then Integer.compare of two returned ints. 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment