Location: Make sure type ANY cannot have ID.

This commit is contained in:
Andreas Schildbach 2016-10-22 12:16:14 +02:00
parent 80f0f30df5
commit c396ebe508

View file

@ -56,7 +56,9 @@ public final class Location implements Serializable {
checkArgument(id == null || id.length() > 0, "ID cannot be the empty string");
checkArgument(place == null || name != null, "place '%s' without name cannot exist", place);
if (type == LocationType.COORD) {
if (type == LocationType.ANY) {
checkArgument(id == null, "type ANY cannot have ID");
} else if (type == LocationType.COORD) {
checkArgument(hasLocation(), "coordinates missing");
checkArgument(place == null && name == null, "coordinates cannot have place or name");
}