diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-13 22:38:13 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-13 22:38:13 +1200 |
commit | abb2f8614b7fbc25892e277b55fa216c7d81fd54 (patch) | |
tree | fea9e46e90d734c8052d81120c65fd50f492ee30 /src/org/traccar/geocode | |
parent | 8e033d5d4efa6a88f25e86517f858b696b76546c (diff) | |
download | traccar-server-abb2f8614b7fbc25892e277b55fa216c7d81fd54.tar.gz traccar-server-abb2f8614b7fbc25892e277b55fa216c7d81fd54.tar.bz2 traccar-server-abb2f8614b7fbc25892e277b55fa216c7d81fd54.zip |
Use switch statemens with strings
Diffstat (limited to 'src/org/traccar/geocode')
-rw-r--r-- | src/org/traccar/geocode/GoogleReverseGeocoder.java | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/org/traccar/geocode/GoogleReverseGeocoder.java b/src/org/traccar/geocode/GoogleReverseGeocoder.java index df8d99545..c37d4188f 100644 --- a/src/org/traccar/geocode/GoogleReverseGeocoder.java +++ b/src/org/traccar/geocode/GoogleReverseGeocoder.java @@ -15,14 +15,9 @@ */ package org.traccar.geocode; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonObject; import javax.json.JsonString; -import org.traccar.helper.Log; public class GoogleReverseGeocoder extends JsonReverseGeocoder { @@ -45,28 +40,34 @@ public class GoogleReverseGeocoder extends JsonReverseGeocoder { String value = component.getString("short_name"); for (JsonString type : component.getJsonArray("types").getValuesAs(JsonString.class)) { - if (type.getString().equals("street_number")) { - address.setHouse(value); - break; - } else if (type.getString().equals("route")) { - address.setStreet(value); - break; - } else if (type.getString().equals("locality")) { - address.setSettlement(value); - break; - } else if (type.getString().equals("administrative_area_level_2")) { - address.setDistrict(value); - break; - } else if (type.getString().equals("administrative_area_level_1")) { - address.setState(value); - break; - } else if (type.getString().equals("country")) { - address.setCountry(value); - break; - } else if (type.getString().equals("postal_code")) { - address.setPostcode(value); - break; + + switch (type.getString()) { + case "street_number": + address.setHouse(value); + break; + case "route": + address.setStreet(value); + break; + case "locality": + address.setSettlement(value); + break; + case "administrative_area_level_2": + address.setDistrict(value); + break; + case "administrative_area_level_1": + address.setState(value); + break; + case "country": + address.setCountry(value); + break; + case "postal_code": + address.setPostcode(value); + break; + default: + continue; } + + break; } } |