Class 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.
      • 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 JsonValues 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.