aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/sorting/DifficultyComparator.java
blob: cb16b7ca4d90f67945d02848fe79034e739d94ff (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 difficulty
 *
 */
public class DifficultyComparator extends AbstractCacheComparator {

	@Override
	protected boolean canCompare(cgCache cache1, cgCache cache2) {
		return cache1.difficulty != null && cache2.difficulty != null;
	}

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