aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/sorting/RatingComparator.java
blob: 62854fe28a5671b13a6939a8c571aae49ccd0519 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package cgeo.geocaching.sorting;

import cgeo.geocaching.Geocache;

/**
 * sorts caches by gcvote.com rating
 *
 */
class RatingComparator extends AbstractCacheComparator {

    @Override
    protected int compareCaches(final Geocache cache1, final Geocache cache2) {
        final float rating1 = cache1.getRating();
        final float rating2 = cache2.getRating();
        // Voting can be disabled for caches, then assume an average rating instead
        return Float.compare(rating2 != 0.0 ? rating2 : 2.5f, rating1 != 0.0 ? rating1 : 2.5f);
    }
}