Class JsonStreetsideSequencesDecoder
- java.lang.Object
-
- org.openstreetmap.josm.plugins.streetside.utils.api.JsonStreetsideSequencesDecoder
-
public final class JsonStreetsideSequencesDecoder extends java.lang.Object
Decodes the JSON returned byStreetsideURL.APIv3into Java objects. Takes aJsonObjectanddecodeSequence(JsonObject)tries to convert it to aStreetsideSequence.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateJsonStreetsideSequencesDecoder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StreetsideImagedecodeBubbleData(StreetsideImage image)Parses a givenStreetsideImageas a GeoJSON Feature into aStreetsideSequence.private static <T> T[]decodeCoordinateProperty(javax.json.JsonObject json, java.lang.String key, java.util.function.Function<javax.json.JsonValue,T> decodeValueFunction, java.lang.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, java.util.function.Function<javax.json.JsonValue,T> decodeValueFunction, java.lang.Class<T> clazz)Converts aJsonArrayto a java array.private static LatLon[]decodeLatLons(javax.json.JsonObject json)static StreetsideSequencedecodeSequence(javax.json.JsonObject json)Parses a givenJsonObjectas a GeoJSON Feature into aStreetsideSequence.static StreetsideSequencedecodeStreetsideSequence(javax.json.JsonObject json)Parses a givenJsonObjectas a GeoJSON Feature into aStreetsideSequence.
-
-
-
Constructor Detail
-
JsonStreetsideSequencesDecoder
private JsonStreetsideSequencesDecoder()
-
-
Method Detail
-
decodeSequence
public static StreetsideSequence decodeSequence(javax.json.JsonObject json)
Parses a givenJsonObjectas a GeoJSON Feature into aStreetsideSequence.- Parameters:
json- theJsonObjectto be parsed- Returns:
- a
StreetsideSequencethat is parsed from the givenJsonObject. If mandatory information is missing from the JSON or it's not meeting the expecting format in another way,nullwill be returned.
-
decodeBubbleData
public static StreetsideImage decodeBubbleData(StreetsideImage image)
Parses a givenStreetsideImageas a GeoJSON Feature into aStreetsideSequence.- Parameters:
image- theStreetsideImageto be parsed- Returns:
- a
StreetsideSequencethat is parsed from the givenJsonObject. If mandatory information is missing from the JSON or it's not meeting the expecting format in another way,nullwill be returned.
-
decodeStreetsideSequence
public static StreetsideSequence decodeStreetsideSequence(javax.json.JsonObject json)
Parses a givenJsonObjectas a GeoJSON Feature into aStreetsideSequence.- Parameters:
json- theJsonObjectto be parsed- Returns:
- a
StreetsideSequencethat is parsed from the givenJsonObject. If mandatory information is missing from the JSON or it's not meeting the expecting format in another way,nullwill be returned.
-
decodeJsonArray
private static <T> T[] decodeJsonArray(javax.json.JsonArray array, java.util.function.Function<javax.json.JsonValue,T> decodeValueFunction, java.lang.Class<T> clazz)
Converts aJsonArrayto a java array. The conversion fromJsonValueto a java type is done by the supplied function.- Type Parameters:
T- object type- Parameters:
array- the array to be converteddecodeValueFunction- the function used for conversion fromJsonValueto the desired type.clazz- the desired type that the elements of the resulting array should have- Returns:
- the supplied array converted from
JsonArrayto a java array of the supplied type, converted using the supplied function. Nevernull, in case of array==null, an array of length 0 is returned.
-
decodeCoordinateProperty
private static <T> T[] decodeCoordinateProperty(javax.json.JsonObject json, java.lang.String key, java.util.function.Function<javax.json.JsonValue,T> decodeValueFunction, java.lang.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. For example this is used to convert the `image_keys` JSON array to a String[] array or the `cas` JSON array to a Double[] array.- Type Parameters:
T- object type- Parameters:
json- 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 theJsonValues in the JSON array to java objects of the desired typeclazz- theClassobject of the desired type, that the entries of the resulting array should have- Returns:
- the resulting array, when converting the desired entry of the `coordinateProperties`.
Never
null. 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.
-
decodeLatLons
private static LatLon[] decodeLatLons(javax.json.JsonObject json)
-
-