diff --git a/OsmAnd-java/src/net/osmand/data/MapObject.java b/OsmAnd-java/src/net/osmand/data/MapObject.java index 28b43cec59..3c9eae0751 100644 --- a/OsmAnd-java/src/net/osmand/data/MapObject.java +++ b/OsmAnd-java/src/net/osmand/data/MapObject.java @@ -18,7 +18,7 @@ import net.sf.junidecode.Junidecode; public abstract class MapObject implements Comparable { - public static final Comparator BY_NAME_COMPARATOR = new MapObjectComparator(); + public static final MapObjectComparator BY_NAME_COMPARATOR = new MapObjectComparator(); protected String name = null; @@ -223,7 +223,23 @@ public abstract class MapObject implements Comparable { @Override public int compare(MapObject o1, MapObject o2) { - return collator.compare(o1.getName(l), o2.getName(l)); + if (o1 == null ^ o2 == null) { + return (o1 == null) ? -1 : 1; + } else if (o1 == o2) { + return 0; + } else { + return collator.compare(o1.getName(l), o2.getName(l)); + } + } + + public boolean areEqual(MapObject o1, MapObject o2) { + if (o1 == null ^ o2 == null) { + return false; + } else if (o1 == o2) { + return true; + } else { + return collator.equals(o1.getName(l), o2.getName(l)); + } } }