From ca895596ba8375af7ca2bd497b64aaaca6fe80fd Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Thu, 12 Mar 2015 10:34:08 +0100 Subject: [PATCH] Outlaw empty strings in location IDs. --- enabler/src/de/schildbach/pte/dto/Location.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/enabler/src/de/schildbach/pte/dto/Location.java b/enabler/src/de/schildbach/pte/dto/Location.java index 318796f7..781837a4 100644 --- a/enabler/src/de/schildbach/pte/dto/Location.java +++ b/enabler/src/de/schildbach/pte/dto/Location.java @@ -28,6 +28,7 @@ import javax.annotation.Nullable; import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; import com.google.common.base.Objects; +import com.google.common.base.Strings; /** * @author Andreas Schildbach @@ -50,6 +51,7 @@ public final class Location implements Serializable this.place = place; this.name = name; + checkArgument(id == null || id.length() > 0, "ID cannot be the empty string"); checkArgument(place == null || name != null, "place '%s' without name cannot exist", place); } @@ -112,7 +114,7 @@ public final class Location implements Serializable public final boolean hasId() { - return id != null; + return !Strings.isNullOrEmpty(id); } public final boolean hasLocation()