blob: dd16f08b0c7688ac2728c5ac687a9b4d31808779 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package cgeo.geocaching.sorting;
import cgeo.geocaching.cgCache;
/**
* sorts caches by GC code, therefore effectively sorting by cache age
*
*/
public class GeocodeComparator extends AbstractCacheComparator {
@Override
protected boolean canCompare(cgCache cache1, cgCache cache2) {
return cache1.geocode != null && cache1.geocode.length() > 0
&& cache2.geocode != null && cache2.geocode.length() > 0;
}
@Override
protected int compareCaches(cgCache cache1, cgCache cache2) {
if (cache1.geocode.length() > cache2.geocode.length()) {
return 1;
} else if (cache2.geocode.length() > cache1.geocode.length()) {
return -1;
}
return cache1.geocode.compareToIgnoreCase(cache2.geocode);
}
}
|