diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2011-07-23 21:52:13 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2011-07-23 21:52:13 +0200 |
| commit | 0454ba218fd2d9add5c663c9799b80b59a259eff (patch) | |
| tree | ccabf3e3be73210fdfa4cb39633731e84122f16d /src/cgeo/geocaching/sorting/DifficultyComparator.java | |
| parent | 6d33eb1f7022544c145400845a4f084f1610ffa8 (diff) | |
| download | cgeo-0454ba218fd2d9add5c663c9799b80b59a259eff.zip cgeo-0454ba218fd2d9add5c663c9799b80b59a259eff.tar.gz cgeo-0454ba218fd2d9add5c663c9799b80b59a259eff.tar.bz2 | |
move all comparators to a new package
extract interface and common implementation details of sorting
Diffstat (limited to 'src/cgeo/geocaching/sorting/DifficultyComparator.java')
| -rw-r--r-- | src/cgeo/geocaching/sorting/DifficultyComparator.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/cgeo/geocaching/sorting/DifficultyComparator.java b/src/cgeo/geocaching/sorting/DifficultyComparator.java new file mode 100644 index 0000000..cb16b7c --- /dev/null +++ b/src/cgeo/geocaching/sorting/DifficultyComparator.java @@ -0,0 +1,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; + } +}
\ No newline at end of file |
