mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 08:40:29 +00:00
SuggestLocationsResult: Assert for OK status in getLocations().
This commit is contained in:
parent
907d7f5ad6
commit
4e9ff4d9da
1 changed files with 3 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2014-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
package de.schildbach.pte.dto;
|
package de.schildbach.pte.dto;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -57,10 +58,10 @@ public final class SuggestLocationsResult implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Location> getLocations() {
|
public List<Location> getLocations() {
|
||||||
|
checkState(status == Status.OK, "no locations with status: {}", status);
|
||||||
final List<Location> locations = new ArrayList<>(suggestedLocations.size());
|
final List<Location> locations = new ArrayList<>(suggestedLocations.size());
|
||||||
for (final SuggestedLocation location : suggestedLocations)
|
for (final SuggestedLocation location : suggestedLocations)
|
||||||
locations.add(location.location);
|
locations.add(location.location);
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue