Package com.targomo.client.api.response
Class GeocodingResponse
java.lang.Object
com.targomo.client.api.response.GeocodingResponse
Response of the ESRI geocoding REST service for a requested address. There are two different possible response types:
- (1) the response was an error message (
wasErrorResponse()==true), i.e. error value is set - seeErrorDescription - (2) the request was successful (
wasErrorResponse()==false) thecandidatesvalue is set
Note: It is immutable with a private constructor since it is only meant to be created from the returned json object.
Note: This is not the complete response from the REST service - only relevant information is captured, the remainder
is discarded.
-
Constructor Summary
ConstructorsConstructorDescriptionGeocodingResponse(List<Candidate> candidates, ErrorDescription error, String jsonString) private - not used since this is a POJO only created from a json String -
Method Summary
Modifier and TypeMethodDescriptionstatic GeocodingResponsecreateFromJson(String jsonString) Creates the response from a JSON StringgetError()booleanisEmpty()iterator()toString()Pretty prints theGeocodingResponse, i.e.booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
GeocodingResponse
private - not used since this is a POJO only created from a json String
-
-
Method Details
-
createFromJson
Creates the response from a JSON String- Parameters:
jsonString- to be parsed- Returns:
- the resulting POJO GeocodingResponse
-
getError
- Returns:
- if an error occurred, the
ErrorDescriptionis returned
-
wasErrorResponse
public boolean wasErrorResponse()- Returns:
trueif error was recorded;falseotherwise
-
getCompleteJsonResponseAsString
- Returns:
- the complete JSON response as String
-
getRepresentativeGeocodeOfRequest
- Returns:
- the first (and thus best) candidate coordinates contained in this geocoding response.
- Throws:
NoSuchElementException- when response contains no candidates
-
getRepresentativeCandidate
- Returns:
- the first (and thus best) candidate contained in this geocoding response.
- Throws:
NoSuchElementException- when response contains no candidates
-
toString
Pretty prints theGeocodingResponse, i.e. with indention and line breaks. -
iterator
-
isEmpty
public boolean isEmpty()- Returns:
- true if empty; false otherwise
-