aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/sorting/StateComparator.java
blob: 9488bd9d35e22d1b22def629ff1fc51758637217 (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.Geocache;

/**
 * sort caches by state (normal, disabled, archived)
 *
 */
public class StateComparator extends AbstractCacheComparator {

    @Override
    protected int compareCaches(final Geocache cache1, final Geocache cache2) {
        return getState(cache1) - getState(cache2);
    }

    private static int getState(final Geocache cache) {
        if (cache.isDisabled()) {
            return 1;
        }
        if (cache.isArchived()) {
            return 2;
        }
        return 0;
    }

}