From 0454ba218fd2d9add5c663c9799b80b59a259eff Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Sat, 23 Jul 2011 21:52:13 +0200 Subject: move all comparators to a new package extract interface and common implementation details of sorting --- src/cgeo/geocaching/sorting/NameComparator.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/cgeo/geocaching/sorting/NameComparator.java (limited to 'src/cgeo/geocaching/sorting/NameComparator.java') diff --git a/src/cgeo/geocaching/sorting/NameComparator.java b/src/cgeo/geocaching/sorting/NameComparator.java new file mode 100644 index 0000000..f1c5ae3 --- /dev/null +++ b/src/cgeo/geocaching/sorting/NameComparator.java @@ -0,0 +1,20 @@ +package cgeo.geocaching.sorting; + +import cgeo.geocaching.cgCache; + +/** + * sorts caches by name + * + */ +public class NameComparator extends AbstractCacheComparator { + + @Override + protected boolean canCompare(cgCache cache1, cgCache cache2) { + return cache1.name != null && cache2.name != null; + } + + @Override + protected int compareCaches(cgCache cache1, cgCache cache2) { + return cache1.name.compareToIgnoreCase(cache2.name); + } +} -- cgit v1.1