org.openstreetmap.josm.plugins.streetside.utils.api

## 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 by `StreetsideURL.APIv3` into Java objects. Takes a `JsonObject` and `decodeSequence(JsonObject)` tries to convert it to a `StreetsideSequence`.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `JsonStreetsideSequencesDecoder()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static StreetsideImage` | `decodeBubbleData(StreetsideImage image)` Parses a given `StreetsideImage` as a GeoJSON Feature into a `StreetsideSequence`.
    `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 a `JsonArray` to a java array.
    `private static org.openstreetmap.josm.data.coor.LatLon[]` | `decodeLatLons(javax.json.JsonObject json)`
    `static StreetsideSequence` | `decodeSequence(javax.json.JsonObject json)` Parses a given `JsonObject` as a GeoJSON Feature into a `StreetsideSequence`.
    `static StreetsideSequence` | `decodeStreetsideSequence(javax.json.JsonObject json)` Parses a given `JsonObject` as a GeoJSON Feature into a `StreetsideSequence`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JsonStreetsideSequencesDecoder

          private JsonStreetsideSequencesDecoder()

  - ### Method Detail

    - #### decodeSequence

          public static StreetsideSequence decodeSequence(javax.json.JsonObject json)

      Parses a given `JsonObject` as a GeoJSON Feature into a `StreetsideSequence`.
      Parameters:
        `json` - the `JsonObject` to be parsed
      Returns:
        a `StreetsideSequence` 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.

    - #### decodeBubbleData

          public static StreetsideImage decodeBubbleData(StreetsideImage image)

      Parses a given `StreetsideImage` as a GeoJSON Feature into a `StreetsideSequence`.
      Parameters:
        `image` - the `StreetsideImage` to be parsed
      Returns:
        a `StreetsideSequence` 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.

    - #### decodeStreetsideSequence

          public static StreetsideSequence decodeStreetsideSequence(javax.json.JsonObject json)

      Parses a given `JsonObject` as a GeoJSON Feature into a `StreetsideSequence`.
      Parameters:
        `json` - the `JsonObject` to be parsed
      Returns:
        a `StreetsideSequence` 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.

    - #### 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 a `JsonArray` to a java array. The conversion from `JsonValue` to a java type is done by the supplied function.
      Type Parameters:
        `T` - object type
      Parameters:
        `array` - the array to be converted
        `decodeValueFunction` - the function used for conversion from `JsonValue` to the desired type.
        `clazz` - the desired type that the elements of the resulting array should have
      Returns:
        the supplied array converted from `JsonArray` 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.

    - #### 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 sequence
        `key` - the key, which identifies the desired array inside the `coordinateProperties` object to be converted
        `decodeValueFunction` - a function that converts the `JsonValue`s in the JSON array to java objects of the desired type
        `clazz` - the `Class` object 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 org.openstreetmap.josm.data.coor.LatLon[] decodeLatLons(javax.json.JsonObject json)

JOSM Plugins