01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tctest;
06:
07: import java.util.Comparator;
08:
09: public class NullTolerantComparator implements Comparator {
10:
11: public int compare(Object o1, Object o2) {
12: if (o1 == null && o2 == null) {
13: return 0;
14: }
15: if (o1 == null && o2 != null) {
16: return -1;
17: }
18: if (o1 != null && o2 == null) {
19: return 1;
20: }
21: return ((Comparable) o1).compareTo(o2);
22: }
23: }
|