Make sure places without name cannot exist.

This commit is contained in:
Andreas Schildbach 2014-08-17 12:25:11 +02:00
parent 9b1ece6cdf
commit 544fa018ca

View file

@ -39,6 +39,9 @@ public final class Location implements Serializable
this.lon = lon; this.lon = lon;
this.place = place; this.place = place;
this.name = name; 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) 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.lon = 0;
this.place = place; this.place = place;
this.name = name; 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) 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; return lat != 0 || lon != 0;
} }
public final boolean hasName()
{
return name != null;
}
public final boolean isIdentified() public final boolean isIdentified()
{ {
if (type == LocationType.STATION) if (type == LocationType.STATION)