public final class JsonSequencesDecoder extends Object
StreetsideURL.APIv3
into Java objects.
Takes a JsonObject
and decodeSequence(JsonObject)
tries to convert it to a StreetsideSequence
.Modifier | Constructor and Description |
---|---|
private |
JsonSequencesDecoder() |
Modifier and Type | Method and Description |
---|---|
private static <T> T[] |
decodeCoordinateProperty(javax.json.JsonObject json,
String key,
Function<javax.json.JsonValue,T> decodeValueFunction,
Class<T> clazz)
Given the JSON object representing the `properties` of a sequence, this method converts you one attribute from the
`coordinateProperties` object to an array of appropriate type.
|
private static <T> T[] |
decodeJsonArray(javax.json.JsonArray array,
Function<javax.json.JsonValue,T> decodeValueFunction,
Class<T> clazz)
Converts a
JsonArray to a java array. |
private static LatLon[] |
decodeLatLons(javax.json.JsonObject json) |
static StreetsideSequence |
decodeSequence(javax.json.JsonObject json)
Parses a given
JsonObject as a GeoJSON Feature into a StreetsideSequence . |
private JsonSequencesDecoder()
public static StreetsideSequence decodeSequence(javax.json.JsonObject json)
JsonObject
as a GeoJSON Feature into a StreetsideSequence
.json
- the JsonObject
to be parsedStreetsideSequence
that is parsed from the given JsonObject
. If mandatory information is
missing from the JSON or it's not meeting the expecting format in another way, null
will be
returned.private static <T> T[] decodeJsonArray(javax.json.JsonArray array, Function<javax.json.JsonValue,T> decodeValueFunction, Class<T> clazz)
JsonArray
to a java array.
The conversion from JsonValue
to a java type is done by the supplied function.T
- object typearray
- the array to be converteddecodeValueFunction
- the function used for conversion from JsonValue
to the desired type.clazz
- the desired type that the elements of the resulting array should haveJsonArray
to a java array of the supplied type, converted using
the supplied function. Never null
, in case of array==null, an array of length 0 is returned.private static <T> T[] decodeCoordinateProperty(javax.json.JsonObject json, String key, Function<javax.json.JsonValue,T> decodeValueFunction, Class<T> clazz)
T
- object typejson
- the JSON object representing the `properties` of a sequencekey
- the key, which identifies the desired array inside the `coordinateProperties` object to be converteddecodeValueFunction
- a function that converts the JsonValue
s in the JSON array to java objects of the
desired typeclazz
- the Class
object of the desired type, that the entries of the resulting array should havenull
. If no `coordinateProperties` are set, or if the desired key is not set or is not
an array, then an empty array of the desired type is returned.private static LatLon[] decodeLatLons(javax.json.JsonObject json)