From 2b5970c89b39d4c8fb6282fa82f1767cf9673710 Mon Sep 17 00:00:00 2001 From: Tihomir Mateev Date: Wed, 25 Sep 2024 10:00:17 +0300 Subject: [PATCH] Polishing touches --- .../api/async/RedisJsonAsyncCommands.java | 16 ++++----- .../reactive/RedisJsonReactiveCommands.java | 16 ++++----- .../core/api/sync/RedisJsonCommands.java | 16 ++++----- .../async/NodeSelectionJsonAsyncCommands.java | 16 ++++----- .../api/sync/NodeSelectionJsonCommands.java | 16 ++++----- .../lettuce/core/json/DelegateJsonValue.java | 2 +- .../java/io/lettuce/core/json/JsonType.java | 13 ------- .../java/io/lettuce/core/json/JsonValue.java | 7 ++-- .../core/json/UnproccessedJsonValue.java | 6 ++-- .../core/output/JsonTypeListOutput.java | 1 + .../core/output/JsonValueListOutput.java | 1 + .../coroutines/RedisJsonCoroutinesCommands.kt | 16 ++++----- .../lettuce/core/api/RedisJsonCommands.java | 16 ++++----- .../core/json/DelegateJsonValueUnitTests.java | 8 ++--- .../RedisJsonClusterIntegrationTests.java | 18 +++++----- .../core/json/RedisJsonIntegrationTests.java | 34 +++++++++---------- .../json/UnproccessedJsonValueUnitTests.java | 8 ++--- .../output/JsonValueListOutputUnitTests.java | 4 +-- 18 files changed, 101 insertions(+), 113 deletions(-) diff --git a/src/main/java/io/lettuce/core/api/async/RedisJsonAsyncCommands.java b/src/main/java/io/lettuce/core/api/async/RedisJsonAsyncCommands.java index ecfbc4f50b..74494e2718 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisJsonAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisJsonAsyncCommands.java @@ -29,7 +29,7 @@ public interface RedisJsonAsyncCommands { /** - * Append the JSON values into the array at a given {@link JsonPath} after the last element in said array. + * Append the JSON values into the array at a given {@link JsonPath} after the last element in a said array. * * @param key the key holding the JSON document. * @param jsonPath the {@link JsonPath} pointing to the array inside the document. @@ -40,7 +40,7 @@ public interface RedisJsonAsyncCommands { RedisFuture> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values); /** - * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in said array. + * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in a said array. * * @param key the key holding the JSON document. * @param values one or more {@link JsonValue} to be appended. @@ -139,7 +139,7 @@ public interface RedisJsonAsyncCommands { /** * Trim an array at a given {@link JsonPath} so that it contains only the specified inclusive range of elements. All - * elements with indexes smaller the start range and all elements with indexes bigger the end range are trimmed. + * elements with indexes smaller than the start range and all elements with indexes bigger than the end range are trimmed. *

* Behavior as of RedisJSON v2.0: *

    @@ -195,7 +195,7 @@ public interface RedisJsonAsyncCommands { RedisFuture jsonDel(K key); /** - * Return the value at path in JSON serialized form. + * Return the value at the specified path in JSON serialized form. *

    * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -214,7 +214,7 @@ public interface RedisJsonAsyncCommands { RedisFuture> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths); /** - * Return the value at path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. + * Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. *

    * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -256,7 +256,7 @@ public interface RedisJsonAsyncCommands { RedisFuture jsonMerge(K key, JsonPath jsonPath, JsonValue value); /** - * Return the values at path from multiple key arguments. + * Return the values at the specified path from multiple key arguments. * * @param jsonPath the {@link JsonPath} pointing to the value to fetch. * @param keys the keys holding the {@link JsonValue}s to fetch. @@ -269,7 +269,7 @@ public interface RedisJsonAsyncCommands { * Set or update one or more JSON values according to the specified {@link JsonMsetArgs} *

    * JSON.MSET is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to - * see that some of the keys were updated while others are unchanged. + * see that some keys were updated while others are unchanged. *

    * A JSON value is a hierarchical structure. If you change a value in a specific path - nested values are affected. * @@ -331,7 +331,7 @@ public interface RedisJsonAsyncCommands { /** * Sets the JSON value at a given {@link JsonPath} in the JSON document. *

    - * For new Redis keys the path must be the root. For existing keys, when the entire path exists, the value that it contains + * For new Redis keys, the path must be the root. For existing keys, when the entire path exists, the value that it contains * is replaced with the JSON value. For existing keys, when the path exists, except for the last element, a new child is * added with the JSON value. *

    diff --git a/src/main/java/io/lettuce/core/api/reactive/RedisJsonReactiveCommands.java b/src/main/java/io/lettuce/core/api/reactive/RedisJsonReactiveCommands.java index ccffbb4ab4..de5e060125 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisJsonReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisJsonReactiveCommands.java @@ -30,7 +30,7 @@ public interface RedisJsonReactiveCommands { /** - * Append the JSON values into the array at a given {@link JsonPath} after the last element in said array. + * Append the JSON values into the array at a given {@link JsonPath} after the last element in a said array. * * @param key the key holding the JSON document. * @param jsonPath the {@link JsonPath} pointing to the array inside the document. @@ -41,7 +41,7 @@ public interface RedisJsonReactiveCommands { Flux jsonArrappend(K key, JsonPath jsonPath, JsonValue... values); /** - * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in said array. + * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in a said array. * * @param key the key holding the JSON document. * @param values one or more {@link JsonValue} to be appended. @@ -140,7 +140,7 @@ public interface RedisJsonReactiveCommands { /** * Trim an array at a given {@link JsonPath} so that it contains only the specified inclusive range of elements. All - * elements with indexes smaller the start range and all elements with indexes bigger the end range are trimmed. + * elements with indexes smaller than the start range and all elements with indexes bigger than the end range are trimmed. *

    * Behavior as of RedisJSON v2.0: *

      @@ -196,7 +196,7 @@ public interface RedisJsonReactiveCommands { Mono jsonDel(K key); /** - * Return the value at path in JSON serialized form. + * Return the value at the specified path in JSON serialized form. *

      * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -215,7 +215,7 @@ public interface RedisJsonReactiveCommands { Flux jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths); /** - * Return the value at path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. + * Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. *

      * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -257,7 +257,7 @@ public interface RedisJsonReactiveCommands { Mono jsonMerge(K key, JsonPath jsonPath, JsonValue value); /** - * Return the values at path from multiple key arguments. + * Return the values at the specified path from multiple key arguments. * * @param jsonPath the {@link JsonPath} pointing to the value to fetch. * @param keys the keys holding the {@link JsonValue}s to fetch. @@ -270,7 +270,7 @@ public interface RedisJsonReactiveCommands { * Set or update one or more JSON values according to the specified {@link JsonMsetArgs} *

      * JSON.MSET is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to - * see that some of the keys were updated while others are unchanged. + * see that some keys were updated while others are unchanged. *

      * A JSON value is a hierarchical structure. If you change a value in a specific path - nested values are affected. * @@ -332,7 +332,7 @@ public interface RedisJsonReactiveCommands { /** * Sets the JSON value at a given {@link JsonPath} in the JSON document. *

      - * For new Redis keys the path must be the root. For existing keys, when the entire path exists, the value that it contains + * For new Redis keys, the path must be the root. For existing keys, when the entire path exists, the value that it contains * is replaced with the JSON value. For existing keys, when the path exists, except for the last element, a new child is * added with the JSON value. *

      diff --git a/src/main/java/io/lettuce/core/api/sync/RedisJsonCommands.java b/src/main/java/io/lettuce/core/api/sync/RedisJsonCommands.java index 4c1c594ab5..006e382283 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisJsonCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisJsonCommands.java @@ -28,7 +28,7 @@ public interface RedisJsonCommands { /** - * Append the JSON values into the array at a given {@link JsonPath} after the last element in said array. + * Append the JSON values into the array at a given {@link JsonPath} after the last element in a said array. * * @param key the key holding the JSON document. * @param jsonPath the {@link JsonPath} pointing to the array inside the document. @@ -39,7 +39,7 @@ public interface RedisJsonCommands { List jsonArrappend(K key, JsonPath jsonPath, JsonValue... values); /** - * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in said array. + * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in a said array. * * @param key the key holding the JSON document. * @param values one or more {@link JsonValue} to be appended. @@ -138,7 +138,7 @@ public interface RedisJsonCommands { /** * Trim an array at a given {@link JsonPath} so that it contains only the specified inclusive range of elements. All - * elements with indexes smaller the start range and all elements with indexes bigger the end range are trimmed. + * elements with indexes smaller than the start range and all elements with indexes bigger than the end range are trimmed. *

      * Behavior as of RedisJSON v2.0: *

        @@ -194,7 +194,7 @@ public interface RedisJsonCommands { Long jsonDel(K key); /** - * Return the value at path in JSON serialized form. + * Return the value at the specified path in JSON serialized form. *

        * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -213,7 +213,7 @@ public interface RedisJsonCommands { List jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths); /** - * Return the value at path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. + * Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. *

        * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -255,7 +255,7 @@ public interface RedisJsonCommands { String jsonMerge(K key, JsonPath jsonPath, JsonValue value); /** - * Return the values at path from multiple key arguments. + * Return the values at the specified path from multiple key arguments. * * @param jsonPath the {@link JsonPath} pointing to the value to fetch. * @param keys the keys holding the {@link JsonValue}s to fetch. @@ -268,7 +268,7 @@ public interface RedisJsonCommands { * Set or update one or more JSON values according to the specified {@link JsonMsetArgs} *

        * JSON.MSET is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to - * see that some of the keys were updated while others are unchanged. + * see that some keys were updated while others are unchanged. *

        * A JSON value is a hierarchical structure. If you change a value in a specific path - nested values are affected. * @@ -330,7 +330,7 @@ public interface RedisJsonCommands { /** * Sets the JSON value at a given {@link JsonPath} in the JSON document. *

        - * For new Redis keys the path must be the root. For existing keys, when the entire path exists, the value that it contains + * For new Redis keys, the path must be the root. For existing keys, when the entire path exists, the value that it contains * is replaced with the JSON value. For existing keys, when the path exists, except for the last element, a new child is * added with the JSON value. *

        diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionJsonAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionJsonAsyncCommands.java index efb80d5037..bc4d9229dd 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionJsonAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionJsonAsyncCommands.java @@ -28,7 +28,7 @@ public interface NodeSelectionJsonAsyncCommands { /** - * Append the JSON values into the array at a given {@link JsonPath} after the last element in said array. + * Append the JSON values into the array at a given {@link JsonPath} after the last element in a said array. * * @param key the key holding the JSON document. * @param jsonPath the {@link JsonPath} pointing to the array inside the document. @@ -39,7 +39,7 @@ public interface NodeSelectionJsonAsyncCommands { AsyncExecutions> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values); /** - * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in said array. + * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in a said array. * * @param key the key holding the JSON document. * @param values one or more {@link JsonValue} to be appended. @@ -138,7 +138,7 @@ public interface NodeSelectionJsonAsyncCommands { /** * Trim an array at a given {@link JsonPath} so that it contains only the specified inclusive range of elements. All - * elements with indexes smaller the start range and all elements with indexes bigger the end range are trimmed. + * elements with indexes smaller than the start range and all elements with indexes bigger than the end range are trimmed. *

        * Behavior as of RedisJSON v2.0: *

          @@ -194,7 +194,7 @@ public interface NodeSelectionJsonAsyncCommands { AsyncExecutions jsonDel(K key); /** - * Return the value at path in JSON serialized form. + * Return the value at the specified path in JSON serialized form. *

          * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -213,7 +213,7 @@ public interface NodeSelectionJsonAsyncCommands { AsyncExecutions> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths); /** - * Return the value at path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. + * Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. *

          * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -255,7 +255,7 @@ public interface NodeSelectionJsonAsyncCommands { AsyncExecutions jsonMerge(K key, JsonPath jsonPath, JsonValue value); /** - * Return the values at path from multiple key arguments. + * Return the values at the specified path from multiple key arguments. * * @param jsonPath the {@link JsonPath} pointing to the value to fetch. * @param keys the keys holding the {@link JsonValue}s to fetch. @@ -268,7 +268,7 @@ public interface NodeSelectionJsonAsyncCommands { * Set or update one or more JSON values according to the specified {@link JsonMsetArgs} *

          * JSON.MSET is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to - * see that some of the keys were updated while others are unchanged. + * see that some keys were updated while others are unchanged. *

          * A JSON value is a hierarchical structure. If you change a value in a specific path - nested values are affected. * @@ -330,7 +330,7 @@ public interface NodeSelectionJsonAsyncCommands { /** * Sets the JSON value at a given {@link JsonPath} in the JSON document. *

          - * For new Redis keys the path must be the root. For existing keys, when the entire path exists, the value that it contains + * For new Redis keys, the path must be the root. For existing keys, when the entire path exists, the value that it contains * is replaced with the JSON value. For existing keys, when the path exists, except for the last element, a new child is * added with the JSON value. *

          diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionJsonCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionJsonCommands.java index 5872f7f7c5..0ca886a8b8 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionJsonCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionJsonCommands.java @@ -28,7 +28,7 @@ public interface NodeSelectionJsonCommands { /** - * Append the JSON values into the array at a given {@link JsonPath} after the last element in said array. + * Append the JSON values into the array at a given {@link JsonPath} after the last element in a said array. * * @param key the key holding the JSON document. * @param jsonPath the {@link JsonPath} pointing to the array inside the document. @@ -39,7 +39,7 @@ public interface NodeSelectionJsonCommands { Executions> jsonArrappend(K key, JsonPath jsonPath, JsonValue... values); /** - * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in said array. + * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in a said array. * * @param key the key holding the JSON document. * @param values one or more {@link JsonValue} to be appended. @@ -138,7 +138,7 @@ public interface NodeSelectionJsonCommands { /** * Trim an array at a given {@link JsonPath} so that it contains only the specified inclusive range of elements. All - * elements with indexes smaller the start range and all elements with indexes bigger the end range are trimmed. + * elements with indexes smaller than the start range and all elements with indexes bigger than the end range are trimmed. *

          * Behavior as of RedisJSON v2.0: *

            @@ -194,7 +194,7 @@ public interface NodeSelectionJsonCommands { Executions jsonDel(K key); /** - * Return the value at path in JSON serialized form. + * Return the value at the specified path in JSON serialized form. *

            * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -213,7 +213,7 @@ public interface NodeSelectionJsonCommands { Executions> jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths); /** - * Return the value at path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. + * Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. *

            * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -255,7 +255,7 @@ public interface NodeSelectionJsonCommands { Executions jsonMerge(K key, JsonPath jsonPath, JsonValue value); /** - * Return the values at path from multiple key arguments. + * Return the values at the specified path from multiple key arguments. * * @param jsonPath the {@link JsonPath} pointing to the value to fetch. * @param keys the keys holding the {@link JsonValue}s to fetch. @@ -268,7 +268,7 @@ public interface NodeSelectionJsonCommands { * Set or update one or more JSON values according to the specified {@link JsonMsetArgs} *

            * JSON.MSET is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to - * see that some of the keys were updated while others are unchanged. + * see that some keys were updated while others are unchanged. *

            * A JSON value is a hierarchical structure. If you change a value in a specific path - nested values are affected. * @@ -330,7 +330,7 @@ public interface NodeSelectionJsonCommands { /** * Sets the JSON value at a given {@link JsonPath} in the JSON document. *

            - * For new Redis keys the path must be the root. For existing keys, when the entire path exists, the value that it contains + * For new Redis keys, the path must be the root. For existing keys, when the entire path exists, the value that it contains * is replaced with the JSON value. For existing keys, when the path exists, except for the last element, a new child is * added with the JSON value. *

            diff --git a/src/main/java/io/lettuce/core/json/DelegateJsonValue.java b/src/main/java/io/lettuce/core/json/DelegateJsonValue.java index 75170d24d8..3ca65eb7a7 100644 --- a/src/main/java/io/lettuce/core/json/DelegateJsonValue.java +++ b/src/main/java/io/lettuce/core/json/DelegateJsonValue.java @@ -27,7 +27,7 @@ class DelegateJsonValue implements JsonValue { } @Override - public String toValue() { + public String toString() { return node.toString(); } diff --git a/src/main/java/io/lettuce/core/json/JsonType.java b/src/main/java/io/lettuce/core/json/JsonType.java index 7e432ec36a..0344e8cee2 100644 --- a/src/main/java/io/lettuce/core/json/JsonType.java +++ b/src/main/java/io/lettuce/core/json/JsonType.java @@ -3,19 +3,6 @@ * All rights reserved. * * Licensed under the MIT License. - * - * This file contains contributions from third-party contributors - * licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ package io.lettuce.core.json; diff --git a/src/main/java/io/lettuce/core/json/JsonValue.java b/src/main/java/io/lettuce/core/json/JsonValue.java index 536911079d..2ba6ac20a0 100644 --- a/src/main/java/io/lettuce/core/json/JsonValue.java +++ b/src/main/java/io/lettuce/core/json/JsonValue.java @@ -14,12 +14,11 @@ * The JavaScript Object Notation (JSON) Data Interchange Format, Section 3. Values *

            * Implementations of this interface need to make sure parsing of the JSON is not done inside the event loop thread, used to - * process the data coming from the Redis server, otherwise larger JSON documents might cause performance degradation that spans + * process the data coming from the Redis server; otherwise larger JSON documents might cause performance degradation that spans * across all threads using the driver. * * @see JsonObject * @see JsonArray - * @see io.lettuce.core.codec.RedisCodec * @see RFC 8259 - The JavaScript Object Notation (JSON) Data * Interchange Format * @author Tihomir Mateev @@ -30,9 +29,9 @@ public interface JsonValue { /** * Execute any {@link io.lettuce.core.codec.RedisCodec} decoding and fetch the result. * - * @return the value representation of this {@link JsonValue} based on the codec used + * @return the {@link String} representation of this {@link JsonValue} */ - String toValue(); + String toString(); /** * @return the raw JSON text as a {@link ByteBuffer} diff --git a/src/main/java/io/lettuce/core/json/UnproccessedJsonValue.java b/src/main/java/io/lettuce/core/json/UnproccessedJsonValue.java index 7914a4619d..cfeda343b1 100644 --- a/src/main/java/io/lettuce/core/json/UnproccessedJsonValue.java +++ b/src/main/java/io/lettuce/core/json/UnproccessedJsonValue.java @@ -40,14 +40,14 @@ public UnproccessedJsonValue(ByteBuffer bytes, JsonParser theParser) { } @Override - public String toValue() { + public String toString() { if (isDeserialized()) { - return jsonValue.toValue(); + return jsonValue.toString(); } synchronized (this) { if (isDeserialized()) { - return jsonValue.toValue(); + return jsonValue.toString(); } // if no deserialization took place, so no modification took place diff --git a/src/main/java/io/lettuce/core/output/JsonTypeListOutput.java b/src/main/java/io/lettuce/core/output/JsonTypeListOutput.java index 6bd2f0e713..96f942f280 100644 --- a/src/main/java/io/lettuce/core/output/JsonTypeListOutput.java +++ b/src/main/java/io/lettuce/core/output/JsonTypeListOutput.java @@ -19,6 +19,7 @@ * @param Key type. * @param Value type. * @author Tihomir Mateev + * @since 6.5 */ public class JsonTypeListOutput extends CommandOutput> { diff --git a/src/main/java/io/lettuce/core/output/JsonValueListOutput.java b/src/main/java/io/lettuce/core/output/JsonValueListOutput.java index 56bc82d9ce..389b696624 100644 --- a/src/main/java/io/lettuce/core/output/JsonValueListOutput.java +++ b/src/main/java/io/lettuce/core/output/JsonValueListOutput.java @@ -20,6 +20,7 @@ * @param Key type. * @param Value type. * @author Tihomir Mateev + * @since 6.5 */ public class JsonValueListOutput extends CommandOutput> { diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisJsonCoroutinesCommands.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisJsonCoroutinesCommands.kt index f3378625d2..589cad946c 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisJsonCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisJsonCoroutinesCommands.kt @@ -31,7 +31,7 @@ import io.lettuce.core.json.arguments.JsonSetArgs interface RedisJsonCoroutinesCommands { /** - * Append the JSON values into the array at a given [JsonPath] after the last element in said array. + * Append the JSON values into the array at a given [JsonPath] after the last element in a said array. * * @param key the key holding the JSON document. * @param jsonPath the [JsonPath] pointing to the array inside the document. @@ -42,7 +42,7 @@ interface RedisJsonCoroutinesCommands { suspend fun jsonArrappend(key: K, jsonPath: JsonPath, vararg values: JsonValue): List /** - * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in said array. + * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in a said array. * * @param key the key holding the JSON document. * @param values one or more [JsonValue] to be appended. @@ -141,7 +141,7 @@ interface RedisJsonCoroutinesCommands { /** * Trim an array at a given [JsonPath] so that it contains only the specified inclusive range of elements. All - * elements with indexes smaller the start range and all elements with indexes bigger the end range are trimmed. + * elements with indexes smaller than the start range and all elements with indexes bigger than the end range are trimmed. *

            * Behavior as of RedisJSON v2.0: *

              @@ -197,7 +197,7 @@ interface RedisJsonCoroutinesCommands { suspend fun jsonDel(key: K): Long? /** - * Return the value at path in JSON serialized form. + * Return the value at the specified path in JSON serialized form. *

              * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -216,7 +216,7 @@ interface RedisJsonCoroutinesCommands { suspend fun jsonGet(key: K, options: JsonGetArgs, vararg jsonPaths: JsonPath): List /** - * Return the value at path in JSON serialized form. Uses defaults for the [JsonGetArgs]. + * Return the value at the specified path in JSON serialized form. Uses defaults for the [JsonGetArgs]. *

              * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -258,7 +258,7 @@ interface RedisJsonCoroutinesCommands { suspend fun jsonMerge(key: K, jsonPath: JsonPath, value: JsonValue): String? /** - * Return the values at path from multiple key arguments. + * Return the values at the specified path from multiple key arguments. * * @param jsonPath the [JsonPath] pointing to the value to fetch. * @param keys the keys holding the [JsonValue]s to fetch. @@ -271,7 +271,7 @@ interface RedisJsonCoroutinesCommands { * Set or update one or more JSON values according to the specified [JsonMsetArgs] *

              * JSON.MSET is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to - * see that some of the keys were updated while others are unchanged. + * see that some keys were updated while others are unchanged. *

              * A JSON value is a hierarchical structure. If you change a value in a specific path - nested values are affected. * @@ -333,7 +333,7 @@ interface RedisJsonCoroutinesCommands { /** * Sets the JSON value at a given [JsonPath] in the JSON document. *

              - * For new Redis keys the path must be the root. For existing keys, when the entire path exists, the value that it contains + * For new Redis keys, the path must be the root. For existing keys, when the entire path exists, the value that it contains * is replaced with the JSON value. For existing keys, when the path exists, except for the last element, a new child is * added with the JSON value. *

              diff --git a/src/main/templates/io/lettuce/core/api/RedisJsonCommands.java b/src/main/templates/io/lettuce/core/api/RedisJsonCommands.java index f493c3c1c1..fdc9dc2040 100644 --- a/src/main/templates/io/lettuce/core/api/RedisJsonCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisJsonCommands.java @@ -28,7 +28,7 @@ public interface RedisJsonCommands { /** - * Append the JSON values into the array at a given {@link JsonPath} after the last element in said array. + * Append the JSON values into the array at a given {@link JsonPath} after the last element in a said array. * * @param key the key holding the JSON document. * @param jsonPath the {@link JsonPath} pointing to the array inside the document. @@ -39,7 +39,7 @@ public interface RedisJsonCommands { List jsonArrappend(K key, JsonPath jsonPath, JsonValue... values); /** - * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in said array. + * Append the JSON values into the array at the {@link JsonPath#ROOT_PATH} after the last element in a said array. * * @param key the key holding the JSON document. * @param values one or more {@link JsonValue} to be appended. @@ -138,7 +138,7 @@ public interface RedisJsonCommands { /** * Trim an array at a given {@link JsonPath} so that it contains only the specified inclusive range of elements. All - * elements with indexes smaller the start range and all elements with indexes bigger the end range are trimmed. + * elements with indexes smaller than the start range and all elements with indexes bigger than the end range are trimmed. *

              * Behavior as of RedisJSON v2.0: *

                @@ -194,7 +194,7 @@ public interface RedisJsonCommands { Long jsonDel(K key); /** - * Return the value at path in JSON serialized form. + * Return the value at the specified path in JSON serialized form. *

                * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -213,7 +213,7 @@ public interface RedisJsonCommands { List jsonGet(K key, JsonGetArgs options, JsonPath... jsonPaths); /** - * Return the value at path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. + * Return the value at the specified path in JSON serialized form. Uses defaults for the {@link JsonGetArgs}. *

                * When using a single JSONPath, the root of the matching values is a JSON string with a top-level array of serialized JSON * value. In contrast, a legacy path returns a single value. @@ -255,7 +255,7 @@ public interface RedisJsonCommands { String jsonMerge(K key, JsonPath jsonPath, JsonValue value); /** - * Return the values at path from multiple key arguments. + * Return the values at the specified path from multiple key arguments. * * @param jsonPath the {@link JsonPath} pointing to the value to fetch. * @param keys the keys holding the {@link JsonValue}s to fetch. @@ -268,7 +268,7 @@ public interface RedisJsonCommands { * Set or update one or more JSON values according to the specified {@link JsonMsetArgs} *

                * JSON.MSET is atomic, hence, all given additions or updates are either applied or not. It is not possible for clients to - * see that some of the keys were updated while others are unchanged. + * see that some keys were updated while others are unchanged. *

                * A JSON value is a hierarchical structure. If you change a value in a specific path - nested values are affected. * @@ -330,7 +330,7 @@ public interface RedisJsonCommands { /** * Sets the JSON value at a given {@link JsonPath} in the JSON document. *

                - * For new Redis keys the path must be the root. For existing keys, when the entire path exists, the value that it contains + * For new Redis keys, the path must be the root. For existing keys, when the entire path exists, the value that it contains * is replaced with the JSON value. For existing keys, when the path exists, except for the last element, a new child is * added with the JSON value. *

                diff --git a/src/test/java/io/lettuce/core/json/DelegateJsonValueUnitTests.java b/src/test/java/io/lettuce/core/json/DelegateJsonValueUnitTests.java index 3c6e797f5f..5fab965057 100644 --- a/src/test/java/io/lettuce/core/json/DelegateJsonValueUnitTests.java +++ b/src/test/java/io/lettuce/core/json/DelegateJsonValueUnitTests.java @@ -21,7 +21,7 @@ void testString() { DefaultJsonParser parser = DefaultJsonParser.INSTANCE; JsonValue underTest = parser.createJsonValue("\"test\""); - assertThat(underTest.toValue()).isEqualTo("\"test\""); + assertThat(underTest.toString()).isEqualTo("\"test\""); assertThat(underTest.asByteBuffer().array()).isEqualTo("\"test\"".getBytes()); assertThat(underTest.isJsonArray()).isFalse(); @@ -47,7 +47,7 @@ void testNumber() { DefaultJsonParser parser = DefaultJsonParser.INSTANCE; JsonValue underTest = parser.createJsonValue("1"); - assertThat(underTest.toValue()).isEqualTo("1"); + assertThat(underTest.toString()).isEqualTo("1"); assertThat(underTest.asByteBuffer().array()).isEqualTo("1".getBytes()); assertThat(underTest.isJsonArray()).isFalse(); @@ -95,7 +95,7 @@ void testBoolean() { DefaultJsonParser parser = DefaultJsonParser.INSTANCE; JsonValue underTest = parser.createJsonValue("true"); - assertThat(underTest.toValue()).isEqualTo("true"); + assertThat(underTest.toString()).isEqualTo("true"); assertThat(underTest.asByteBuffer().array()).isEqualTo("true".getBytes()); assertThat(underTest.isJsonArray()).isFalse(); @@ -121,7 +121,7 @@ void testNull() { DefaultJsonParser parser = DefaultJsonParser.INSTANCE; JsonValue underTest = parser.createJsonValue("null"); - assertThat(underTest.toValue()).isEqualTo("null"); + assertThat(underTest.toString()).isEqualTo("null"); assertThat(underTest.asByteBuffer().array()).isEqualTo("null".getBytes()); assertThat(underTest.isJsonArray()).isFalse(); diff --git a/src/test/java/io/lettuce/core/json/RedisJsonClusterIntegrationTests.java b/src/test/java/io/lettuce/core/json/RedisJsonClusterIntegrationTests.java index 39414fbf99..7c2746d4c0 100644 --- a/src/test/java/io/lettuce/core/json/RedisJsonClusterIntegrationTests.java +++ b/src/test/java/io/lettuce/core/json/RedisJsonClusterIntegrationTests.java @@ -128,7 +128,7 @@ void jsonArrpop(String path) { List poppedJson = redis.jsonArrpop(BIKES_INVENTORY, myPath, -1); assertThat(poppedJson).hasSize(1); - assertThat(poppedJson.get(0).toValue()).contains( + assertThat(poppedJson.get(0).toString()).contains( "{\"id\":\"bike:3\",\"model\":\"Weywot\",\"description\":\"This bike gives kids aged six years and old"); } @@ -164,13 +164,13 @@ void jsonGet(String path) { assertThat(value).hasSize(1); if (path.startsWith("$")) { - assertThat(value.get(0).toValue()).isEqualTo("[\"Phoebe\",\"Quaoar\"]"); + assertThat(value.get(0).toString()).isEqualTo("[\"Phoebe\",\"Quaoar\"]"); // Verify array parsing assertThat(value.get(0).isJsonArray()).isTrue(); assertThat(value.get(0).asJsonArray().size()).isEqualTo(2); - assertThat(value.get(0).asJsonArray().asList().get(0).toValue()).isEqualTo("\"Phoebe\""); - assertThat(value.get(0).asJsonArray().asList().get(1).toValue()).isEqualTo("\"Quaoar\""); + assertThat(value.get(0).asJsonArray().asList().get(0).toString()).isEqualTo("\"Phoebe\""); + assertThat(value.get(0).asJsonArray().asList().get(1).toString()).isEqualTo("\"Quaoar\""); // Verify String parsing assertThat(value.get(0).asJsonArray().asList().get(0).isString()).isTrue(); @@ -178,7 +178,7 @@ void jsonGet(String path) { assertThat(value.get(0).asJsonArray().asList().get(1).isString()).isTrue(); assertThat(value.get(0).asJsonArray().asList().get(1).asString()).isEqualTo("Quaoar"); } else { - assertThat(value.get(0).toValue()).isEqualTo("\"Phoebe\""); + assertThat(value.get(0).toString()).isEqualTo("\"Phoebe\""); // Verify array parsing assertThat(value.get(0).isString()).isTrue(); @@ -206,9 +206,9 @@ void jsonMGet(String path) { List value = redis.jsonMGet(myPath, BIKES_INVENTORY); assertThat(value).hasSize(1); if (path.startsWith("$")) { - assertThat(value.get(0).toValue()).isEqualTo("[\"Phoebe\",\"Quaoar\",\"Weywot\"]"); + assertThat(value.get(0).toString()).isEqualTo("[\"Phoebe\",\"Quaoar\",\"Weywot\"]"); } else { - assertThat(value.get(0).toValue()).isEqualTo("\"Phoebe\""); + assertThat(value.get(0).toString()).isEqualTo("\"Phoebe\""); } } @@ -259,8 +259,8 @@ void jsonCrossSlot() { assertThat(value).hasSize(2); JsonValue slot1 = value.get(0); JsonValue slot2 = value.get(1); - assertThat(slot1.toValue()).contains("bike:43"); - assertThat(slot2.toValue()).contains("bike:43"); + assertThat(slot1.toString()).contains("bike:43"); + assertThat(slot2.toString()).contains("bike:43"); assertThat(slot1.isJsonArray()).isTrue(); assertThat(slot2.isJsonArray()).isTrue(); } diff --git a/src/test/java/io/lettuce/core/json/RedisJsonIntegrationTests.java b/src/test/java/io/lettuce/core/json/RedisJsonIntegrationTests.java index a8820fb8dd..25ea348c76 100644 --- a/src/test/java/io/lettuce/core/json/RedisJsonIntegrationTests.java +++ b/src/test/java/io/lettuce/core/json/RedisJsonIntegrationTests.java @@ -133,7 +133,7 @@ void jsonArrpop(String path) { List poppedJson = redis.jsonArrpop(BIKES_INVENTORY, myPath); assertThat(poppedJson).hasSize(1); - assertThat(poppedJson.get(0).toValue()).contains( + assertThat(poppedJson.get(0).toString()).contains( "{\"id\":\"bike:3\",\"model\":\"Weywot\",\"description\":\"This bike gives kids aged six years and old"); } @@ -169,13 +169,13 @@ void jsonGet(String path) { assertThat(value).hasSize(1); if (path.startsWith("$")) { - assertThat(value.get(0).toValue()).isEqualTo("[\"Phoebe\",\"Quaoar\"]"); + assertThat(value.get(0).toString()).isEqualTo("[\"Phoebe\",\"Quaoar\"]"); // Verify array parsing assertThat(value.get(0).isJsonArray()).isTrue(); assertThat(value.get(0).asJsonArray().size()).isEqualTo(2); - assertThat(value.get(0).asJsonArray().asList().get(0).toValue()).isEqualTo("\"Phoebe\""); - assertThat(value.get(0).asJsonArray().asList().get(1).toValue()).isEqualTo("\"Quaoar\""); + assertThat(value.get(0).asJsonArray().asList().get(0).toString()).isEqualTo("\"Phoebe\""); + assertThat(value.get(0).asJsonArray().asList().get(1).toString()).isEqualTo("\"Quaoar\""); // Verify String parsing assertThat(value.get(0).asJsonArray().asList().get(0).isString()).isTrue(); @@ -184,7 +184,7 @@ void jsonGet(String path) { assertThat(value.get(0).asJsonArray().asList().get(1).isNull()).isFalse(); assertThat(value.get(0).asJsonArray().asList().get(1).asString()).isEqualTo("Quaoar"); } else { - assertThat(value.get(0).toValue()).isEqualTo("\"Phoebe\""); + assertThat(value.get(0).toString()).isEqualTo("\"Phoebe\""); // Verify array parsing assertThat(value.get(0).isString()).isTrue(); @@ -200,12 +200,12 @@ void jsonGetNull() { List value = redis.jsonGet(BIKES_INVENTORY, myPath); assertThat(value).hasSize(1); - assertThat(value.get(0).toValue()).isEqualTo("[null]"); + assertThat(value.get(0).toString()).isEqualTo("[null]"); // Verify array parsing assertThat(value.get(0).isJsonArray()).isTrue(); assertThat(value.get(0).asJsonArray().size()).isEqualTo(1); - assertThat(value.get(0).asJsonArray().asList().get(0).toValue()).isEqualTo("null"); + assertThat(value.get(0).asJsonArray().asList().get(0).toString()).isEqualTo("null"); assertThat(value.get(0).asJsonArray().asList().get(0).isNull()).isTrue(); } @@ -229,9 +229,9 @@ void jsonMGet(String path) { List value = redis.jsonMGet(myPath, BIKES_INVENTORY); assertThat(value).hasSize(1); if (path.startsWith("$")) { - assertThat(value.get(0).toValue()).isEqualTo("[\"Phoebe\",\"Quaoar\",\"Weywot\"]"); + assertThat(value.get(0).toString()).isEqualTo("[\"Phoebe\",\"Quaoar\",\"Weywot\"]"); } else { - assertThat(value.get(0).toValue()).isEqualTo("\"Phoebe\""); + assertThat(value.get(0).toString()).isEqualTo("\"Phoebe\""); } } @@ -283,7 +283,7 @@ void jsonMset(String path) { assertThat(value).isNotNull(); assertThat(value.isJsonArray()).isTrue(); assertThat(value.asJsonArray().size()).isEqualTo(1); - assertThat(value.asJsonArray().asList().get(0).toValue()).contains( + assertThat(value.asJsonArray().asList().get(0).toString()).contains( "{\"id\":\"bike:13\",\"model\":\"Woody\",\"description\":\"The Woody is an environmentally-friendly wooden bike\""); } @@ -334,7 +334,7 @@ void jsonMsetCrossslot() { assertThat(value).isNotNull(); assertThat(value.isJsonArray()).isTrue(); assertThat(value.asJsonArray().size()).isEqualTo(1); - assertThat(value.asJsonArray().asList().get(0).toValue()).contains( + assertThat(value.asJsonArray().asList().get(0).toString()).contains( "{\"id\":\"bike:13\",\"model\":\"Woody\",\"description\":\"The Woody is an environmentally-friendly wooden bike\""); } @@ -544,13 +544,13 @@ void jsonSetFromObject() { assertThat(newValue.isNull()).isFalse(); assertThat(newValue.isJsonObject()).isTrue(); assertThat(newValue.asJsonObject().size()).isEqualTo(6); - assertThat(newValue.asJsonObject().get("id").toValue()).isEqualTo("\"bike:43\""); - assertThat(newValue.asJsonObject().get("model").toValue()).isEqualTo("\"DesertFox\""); - assertThat(newValue.asJsonObject().get("description").toValue()) + assertThat(newValue.asJsonObject().get("id").toString()).isEqualTo("\"bike:43\""); + assertThat(newValue.asJsonObject().get("model").toString()).isEqualTo("\"DesertFox\""); + assertThat(newValue.asJsonObject().get("description").toString()) .isEqualTo("\"The DesertFox is a versatile bike for all terrains\""); - assertThat(newValue.asJsonObject().get("price").toValue()).isEqualTo("\"1299\""); - assertThat(newValue.asJsonObject().get("specs").toValue()).isEqualTo("{\"material\":\"composite\",\"weight\":\"11\"}"); - assertThat(newValue.asJsonObject().get("colors").toValue()).isEqualTo("[\"yellow\",\"orange\"]"); + assertThat(newValue.asJsonObject().get("price").toString()).isEqualTo("\"1299\""); + assertThat(newValue.asJsonObject().get("specs").toString()).isEqualTo("{\"material\":\"composite\",\"weight\":\"11\"}"); + assertThat(newValue.asJsonObject().get("colors").toString()).isEqualTo("[\"yellow\",\"orange\"]"); String result = redis.jsonSet(BIKES_INVENTORY, myPath, newValue); diff --git a/src/test/java/io/lettuce/core/json/UnproccessedJsonValueUnitTests.java b/src/test/java/io/lettuce/core/json/UnproccessedJsonValueUnitTests.java index 0b1821f33a..369bae1689 100644 --- a/src/test/java/io/lettuce/core/json/UnproccessedJsonValueUnitTests.java +++ b/src/test/java/io/lettuce/core/json/UnproccessedJsonValueUnitTests.java @@ -34,7 +34,7 @@ class UnproccessedJsonValueUnitTests { @Test - void toValue() { + void asString() { final String unprocessed = "{\"a\":1,\"b\":2}"; final String modified = "{\"a\":1}"; @@ -43,13 +43,13 @@ void toValue() { UnproccessedJsonValue underTest = new UnproccessedJsonValue(buffer, parser); String value = StringCodec.UTF8.decodeValue(buffer); - assertThat(underTest.toValue()).isEqualTo(value); + assertThat(underTest.toString()).isEqualTo(value); assertThat(underTest.asByteBuffer()).isEqualTo(ByteBuffer.wrap(unprocessed.getBytes())); assertThat(underTest.isJsonObject()).isTrue(); assertThat(underTest.asJsonObject().remove("b")).isNotNull(); - assertThat(underTest.toValue()).isEqualTo(modified); + assertThat(underTest.toString()).isEqualTo(modified); assertThat(underTest.asByteBuffer()).isEqualTo(ByteBuffer.wrap(modified.getBytes())); } @@ -127,7 +127,7 @@ void asArray() { UnproccessedJsonValue underTest = new UnproccessedJsonValue(buffer, parser); assertThat(underTest.isJsonArray()).isTrue(); - assertThat(underTest.asJsonArray().toValue()).isEqualTo("[1,2,3,4]"); + assertThat(underTest.asJsonArray().toString()).isEqualTo("[1,2,3,4]"); Assertions.assertThat(underTest.isNumber()).isFalse(); Assertions.assertThat(underTest.isString()).isFalse(); diff --git a/src/test/java/io/lettuce/core/output/JsonValueListOutputUnitTests.java b/src/test/java/io/lettuce/core/output/JsonValueListOutputUnitTests.java index 83e44866c4..0406133881 100644 --- a/src/test/java/io/lettuce/core/output/JsonValueListOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/JsonValueListOutputUnitTests.java @@ -29,8 +29,8 @@ void set() { assertThat(sut.get().isEmpty()).isFalse(); assertThat(sut.get().size()).isEqualTo(2); - assertThat(sut.get().get(0).toValue()).isEqualTo("[1,2,3]"); - assertThat(sut.get().get(1).toValue()).isEqualTo("world"); + assertThat(sut.get().get(0).toString()).isEqualTo("[1,2,3]"); + assertThat(sut.get().get(1).toString()).isEqualTo("world"); } }