aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/sorting/PopularityComparator.java
blob: 9fe254af59c8338e4280d0a38cfd468bdeae4fd2 (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
package cgeo.geocaching.sorting;

import cgeo.geocaching.cgCache;

/**
 * sorts caches by popularity (favorite count)
 *
 */
public class PopularityComparator extends AbstractCacheComparator {

    @Override
    protected boolean canCompare(cgCache cache1, cgCache cache2) {
        return true;
    }

    @Override
    protected int compareCaches(cgCache cache1, cgCache cache2) {
        if (cache1.getFavoritePoints() < cache2.getFavoritePoints()) {
            return 1;
        } else if (cache2.getFavoritePoints() < cache1.getFavoritePoints()) {
            return -1;
        }
        return 0;
    }
}