Outlaw empty strings in location IDs.

This commit is contained in:
Andreas Schildbach 2015-03-12 10:34:08 +01:00
parent 95d0a31675
commit ca895596ba

View file

@ -28,6 +28,7 @@ import javax.annotation.Nullable;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper; import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Strings;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
@ -50,6 +51,7 @@ public final class Location implements Serializable
this.place = place; this.place = place;
this.name = name; 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); 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() public final boolean hasId()
{ {
return id != null; return !Strings.isNullOrEmpty(id);
} }
public final boolean hasLocation() public final boolean hasLocation()