From 544fa018cac209cbbb610c9e60584e282df743a3 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Sun, 17 Aug 2014 12:25:11 +0200 Subject: [PATCH] Make sure places without name cannot exist. --- enabler/src/de/schildbach/pte/dto/Location.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/enabler/src/de/schildbach/pte/dto/Location.java b/enabler/src/de/schildbach/pte/dto/Location.java index eff35386..31c0f1fa 100644 --- a/enabler/src/de/schildbach/pte/dto/Location.java +++ b/enabler/src/de/schildbach/pte/dto/Location.java @@ -39,6 +39,9 @@ public final class Location implements Serializable this.lon = lon; this.place = place; this.name = name; + + if (name == null && place != null) + throw new IllegalArgumentException("places without name cannot exist"); } public Location(final LocationType type, final String id, final String place, final String name) @@ -49,6 +52,9 @@ public final class Location implements Serializable this.lon = 0; this.place = place; this.name = name; + + if (name == null && place != null) + throw new IllegalArgumentException("places without name cannot exist"); } public Location(final LocationType type, final String id, final int lat, final int lon) @@ -91,6 +97,11 @@ public final class Location implements Serializable return lat != 0 || lon != 0; } + public final boolean hasName() + { + return name != null; + } + public final boolean isIdentified() { if (type == LocationType.STATION)