use of com.google.api.services.actions_fulfillment.v2.model.PostalAddress in project dialogflow-transactions-java by actions-on-google.
the class LocationDeserializer method deserialize.
@Override
public Location deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject();
Location location = new Location();
JsonElement city = jsonObject.get("city");
JsonElement coordinates = jsonObject.get("coordinates");
JsonElement name = jsonObject.get("name");
JsonElement notes = jsonObject.get("notes");
JsonElement phoneNumber = jsonObject.get("phoneNumber");
JsonElement placeId = jsonObject.get("placeId");
JsonElement zipCode = jsonObject.get("zipCode");
JsonElement formattedAddress = jsonObject.get("formattedAddress");
JsonElement postalAddress = jsonObject.get("postalAddress");
if (city != null) {
location.setCity(city.getAsString());
}
if (name != null) {
location.setName(name.getAsString());
}
if (notes != null) {
location.setNotes(notes.getAsString());
}
if (phoneNumber != null) {
location.setPhoneNumber(phoneNumber.getAsString());
}
if (placeId != null) {
location.setPlaceId(placeId.getAsString());
}
if (zipCode != null) {
location.setZipCode(zipCode.getAsString());
}
if (formattedAddress != null) {
location.setFormattedAddress(formattedAddress.getAsString());
}
if (postalAddress != null) {
PostalAddress address = context.deserialize(postalAddress.getAsJsonObject(), PostalAddress.class);
location.setPostalAddress(address);
}
if (coordinates != null) {
LatLng coords = context.deserialize(coordinates.getAsJsonObject(), LatLng.class);
location.setCoordinates(coords);
}
return location;
}
Aggregations