aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/sorting/RatingComparator.java
blob: 6f2c61571ee2cffe1ba785f65adea36b57601075 (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
 *
 */
public 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);
    }
}