aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/sorting/InventoryComparator.java
blob: ed4dcb72eb0ea75d875ad1b787bb5c419f2d1294 (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
27
28
29
package cgeo.geocaching.sorting;

import cgeo.geocaching.cgCache;

/**
 * sorts caches by number of items in inventory
 * 
 * @author bananeweizen
 * 
 */
public class InventoryComparator extends AbstractCacheComparator {

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

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