From 948dd7cddc27f884df04937416adec19d7817775 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Tue, 9 Apr 2024 14:00:00 -0700 Subject: [PATCH] Java: misc fixes (#201) * Update javadocs. Signed-off-by: Yury-Fridlyand * Minor fixes there and here. Signed-off-by: Yury-Fridlyand --------- Signed-off-by: Yury-Fridlyand --- .../ConnectionManagementClusterCommands.java | 2 +- .../api/commands/SortedSetBaseCommands.java | 4 +- .../glide/api/models/BaseTransaction.java | 77 ++++--------------- 3 files changed, 19 insertions(+), 64 deletions(-) diff --git a/java/client/src/main/java/glide/api/commands/ConnectionManagementClusterCommands.java b/java/client/src/main/java/glide/api/commands/ConnectionManagementClusterCommands.java index 4cfc991e7c..1ce9e8a511 100644 --- a/java/client/src/main/java/glide/api/commands/ConnectionManagementClusterCommands.java +++ b/java/client/src/main/java/glide/api/commands/ConnectionManagementClusterCommands.java @@ -165,7 +165,7 @@ public interface ConnectionManagementClusterCommands { * @param route Specifies the routing configuration for the command. The client will route the * command to the nodes defined by route. * @return The provided message. - * @examples + * @example *
{@code
      * // Command sent to a single random node via RANDOM route, expecting a SingleValue result.
      * String message = client.echo("GLIDE", RANDOM).get().getSingleValue();
diff --git a/java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java b/java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
index d4a9e5d4ea..1f44f7bcb0 100644
--- a/java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
+++ b/java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
@@ -416,7 +416,7 @@ CompletableFuture> zrangeWithScores(
     /**
      * Returns the rank of member in the sorted set stored at key, with
      * scores ordered from low to high.
- * To get the rank of member with it's score, see zrankWithScore. + * To get the rank of member with its score, see {@link #zrankWithScore}. * * @see redis.io for more details. * @param key The key of the sorted set. @@ -436,7 +436,7 @@ CompletableFuture> zrangeWithScores( CompletableFuture zrank(String key, String member); /** - * Returns the rank of member in the sorted set stored at key with it's + * Returns the rank of member in the sorted set stored at key with its * score, where scores are ordered from the lowest to highest. * * @see redis.io for more details. diff --git a/java/client/src/main/java/glide/api/models/BaseTransaction.java b/java/client/src/main/java/glide/api/models/BaseTransaction.java index 7a7a93b1a2..7865cb1709 100644 --- a/java/client/src/main/java/glide/api/models/BaseTransaction.java +++ b/java/client/src/main/java/glide/api/models/BaseTransaction.java @@ -136,7 +136,6 @@ public abstract class BaseTransaction> { * }
*/ public T customCommand(String[] args) { - ArgsArray commandArgs = buildArgs(args); protobufTransaction.addCommands(buildCommand(CustomCommand, commandArgs)); return getThis(); @@ -175,7 +174,6 @@ public T ping() { */ public T ping(@NonNull String msg) { ArgsArray commandArgs = buildArgs(msg); - protobufTransaction.addCommands(buildCommand(Ping, commandArgs)); return getThis(); } @@ -202,7 +200,6 @@ public T info() { */ public T info(@NonNull InfoOptions options) { ArgsArray commandArgs = buildArgs(options.toArgs()); - protobufTransaction.addCommands(buildCommand(Info, commandArgs)); return getThis(); } @@ -217,7 +214,6 @@ public T info(@NonNull InfoOptions options) { */ public T del(@NonNull String[] keys) { ArgsArray commandArgs = buildArgs(keys); - protobufTransaction.addCommands(buildCommand(Del, commandArgs)); return getThis(); } @@ -232,7 +228,6 @@ public T del(@NonNull String[] keys) { */ public T get(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(GetString, commandArgs)); return getThis(); } @@ -247,7 +242,6 @@ public T get(@NonNull String key) { */ public T set(@NonNull String key, @NonNull String value) { ArgsArray commandArgs = buildArgs(key, value); - protobufTransaction.addCommands(buildCommand(SetString, commandArgs)); return getThis(); } @@ -285,7 +279,6 @@ public T set(@NonNull String key, @NonNull String value, @NonNull SetOptions opt */ public T mget(@NonNull String[] keys) { ArgsArray commandArgs = buildArgs(keys); - protobufTransaction.addCommands(buildCommand(MGet, commandArgs)); return getThis(); } @@ -315,7 +308,6 @@ public T mset(@NonNull Map keyValueMap) { */ public T incr(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(Incr, commandArgs)); return getThis(); } @@ -331,7 +323,6 @@ public T incr(@NonNull String key) { */ public T incrBy(@NonNull String key, long amount) { ArgsArray commandArgs = buildArgs(key, Long.toString(amount)); - protobufTransaction.addCommands(buildCommand(IncrBy, commandArgs)); return getThis(); } @@ -349,7 +340,6 @@ public T incrBy(@NonNull String key, long amount) { */ public T incrByFloat(@NonNull String key, double amount) { ArgsArray commandArgs = buildArgs(key, Double.toString(amount)); - protobufTransaction.addCommands(buildCommand(IncrByFloat, commandArgs)); return getThis(); } @@ -364,7 +354,6 @@ public T incrByFloat(@NonNull String key, double amount) { */ public T decr(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(Decr, commandArgs)); return getThis(); } @@ -380,7 +369,6 @@ public T decr(@NonNull String key) { */ public T decrBy(@NonNull String key, long amount) { ArgsArray commandArgs = buildArgs(key, Long.toString(amount)); - protobufTransaction.addCommands(buildCommand(DecrBy, commandArgs)); return getThis(); } @@ -411,7 +399,6 @@ public T strlen(@NonNull String key) { */ public T hget(@NonNull String key, @NonNull String field) { ArgsArray commandArgs = buildArgs(key, field); - protobufTransaction.addCommands(buildCommand(HashGet, commandArgs)); return getThis(); } @@ -448,7 +435,6 @@ public T hset(@NonNull String key, @NonNull Map fieldValueMap) { */ public T hsetnx(@NonNull String key, @NonNull String field, @NonNull String value) { ArgsArray commandArgs = buildArgs(key, field, value); - protobufTransaction.addCommands(buildCommand(HSetNX, commandArgs)); return getThis(); } @@ -466,7 +452,6 @@ public T hsetnx(@NonNull String key, @NonNull String field, @NonNull String valu */ public T hdel(@NonNull String key, @NonNull String[] fields) { ArgsArray commandArgs = buildArgs(ArrayUtils.addFirst(fields, key)); - protobufTransaction.addCommands(buildCommand(HashDel, commandArgs)); return getThis(); } @@ -482,7 +467,6 @@ public T hdel(@NonNull String key, @NonNull String[] fields) { */ public T hlen(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(HLen, commandArgs)); return getThis(); } @@ -497,7 +481,6 @@ public T hlen(@NonNull String key) { */ public T hvals(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(Hvals, commandArgs)); return getThis(); } @@ -516,7 +499,6 @@ public T hvals(@NonNull String key) { */ public T hmget(@NonNull String key, @NonNull String[] fields) { ArgsArray commandArgs = buildArgs(ArrayUtils.addFirst(fields, key)); - protobufTransaction.addCommands(buildCommand(HashMGet, commandArgs)); return getThis(); } @@ -533,7 +515,6 @@ public T hmget(@NonNull String key, @NonNull String[] fields) { */ public T hexists(@NonNull String key, @NonNull String field) { ArgsArray commandArgs = buildArgs(key, field); - protobufTransaction.addCommands(buildCommand(HashExists, commandArgs)); return getThis(); } @@ -549,7 +530,6 @@ public T hexists(@NonNull String key, @NonNull String field) { */ public T hgetall(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(HashGetAll, commandArgs)); return getThis(); } @@ -571,7 +551,6 @@ public T hgetall(@NonNull String key) { */ public T hincrBy(@NonNull String key, @NonNull String field, long amount) { ArgsArray commandArgs = buildArgs(key, field, Long.toString(amount)); - protobufTransaction.addCommands(buildCommand(HashIncrBy, commandArgs)); return getThis(); } @@ -594,7 +573,6 @@ public T hincrBy(@NonNull String key, @NonNull String field, long amount) { */ public T hincrByFloat(@NonNull String key, @NonNull String field, double amount) { ArgsArray commandArgs = buildArgs(key, field, Double.toString(amount)); - protobufTransaction.addCommands(buildCommand(HashIncrByFloat, commandArgs)); return getThis(); } @@ -612,7 +590,6 @@ public T hincrByFloat(@NonNull String key, @NonNull String field, double amount) */ public T lpush(@NonNull String key, @NonNull String[] elements) { ArgsArray commandArgs = buildArgs(ArrayUtils.addFirst(elements, key)); - protobufTransaction.addCommands(buildCommand(LPush, commandArgs)); return getThis(); } @@ -628,7 +605,6 @@ public T lpush(@NonNull String key, @NonNull String[] elements) { */ public T lpop(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(LPop, commandArgs)); return getThis(); } @@ -646,7 +622,6 @@ public T lpop(@NonNull String key) { */ public T lpopCount(@NonNull String key, long count) { ArgsArray commandArgs = buildArgs(key, Long.toString(count)); - protobufTransaction.addCommands(buildCommand(LPop, commandArgs)); return getThis(); } @@ -672,7 +647,6 @@ public T lpopCount(@NonNull String key, long count) { */ public T lrange(@NonNull String key, long start, long end) { ArgsArray commandArgs = buildArgs(key, Long.toString(start), Long.toString(end)); - protobufTransaction.addCommands(buildCommand(LRange, commandArgs)); return getThis(); } @@ -697,7 +671,6 @@ public T lrange(@NonNull String key, long start, long end) { */ public T ltrim(@NonNull String key, long start, long end) { ArgsArray commandArgs = buildArgs(key, Long.toString(start), Long.toString(end)); - protobufTransaction.addCommands(buildCommand(LTrim, commandArgs)); return getThis(); } @@ -737,7 +710,6 @@ public T llen(@NonNull String key) { */ public T lrem(@NonNull String key, long count, @NonNull String element) { ArgsArray commandArgs = buildArgs(key, Long.toString(count), element); - protobufTransaction.addCommands(buildCommand(LRem, commandArgs)); return getThis(); } @@ -755,7 +727,6 @@ public T lrem(@NonNull String key, long count, @NonNull String element) { */ public T rpush(@NonNull String key, @NonNull String[] elements) { ArgsArray commandArgs = buildArgs(ArrayUtils.addFirst(elements, key)); - protobufTransaction.addCommands(buildCommand(RPush, commandArgs)); return getThis(); } @@ -771,7 +742,6 @@ public T rpush(@NonNull String key, @NonNull String[] elements) { */ public T rpop(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(RPop, commandArgs)); return getThis(); } @@ -788,7 +758,6 @@ public T rpop(@NonNull String key) { */ public T rpopCount(@NonNull String key, long count) { ArgsArray commandArgs = buildArgs(key, Long.toString(count)); - protobufTransaction.addCommands(buildCommand(RPop, commandArgs)); return getThis(); } @@ -807,7 +776,6 @@ public T rpopCount(@NonNull String key, long count) { */ public T sadd(@NonNull String key, @NonNull String[] members) { ArgsArray commandArgs = buildArgs(ArrayUtils.addFirst(members, key)); - protobufTransaction.addCommands(buildCommand(SAdd, commandArgs)); return getThis(); } @@ -824,7 +792,6 @@ public T sadd(@NonNull String key, @NonNull String[] members) { */ public T sismember(@NonNull String key, @NonNull String member) { ArgsArray commandArgs = buildArgs(key, member); - protobufTransaction.addCommands(buildCommand(SIsMember, commandArgs)); return getThis(); } @@ -843,7 +810,6 @@ public T sismember(@NonNull String key, @NonNull String member) { */ public T srem(@NonNull String key, @NonNull String[] members) { ArgsArray commandArgs = buildArgs(ArrayUtils.addFirst(members, key)); - protobufTransaction.addCommands(buildCommand(SRem, commandArgs)); return getThis(); } @@ -858,7 +824,6 @@ public T srem(@NonNull String key, @NonNull String[] members) { */ public T smembers(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(SMembers, commandArgs)); return getThis(); } @@ -873,7 +838,6 @@ public T smembers(@NonNull String key) { */ public T scard(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(SCard, commandArgs)); return getThis(); } @@ -889,7 +853,6 @@ public T scard(@NonNull String key) { */ public T configGet(@NonNull String[] parameters) { ArgsArray commandArgs = buildArgs(parameters); - protobufTransaction.addCommands(buildCommand(ConfigGet, commandArgs)); return getThis(); } @@ -905,7 +868,6 @@ public T configGet(@NonNull String[] parameters) { */ public T configSet(@NonNull Map parameters) { ArgsArray commandArgs = buildArgs(convertMapToKeyValueStringArray(parameters)); - protobufTransaction.addCommands(buildCommand(ConfigSet, commandArgs)); return getThis(); } @@ -920,7 +882,6 @@ public T configSet(@NonNull Map parameters) { */ public T exists(@NonNull String[] keys) { ArgsArray commandArgs = buildArgs(keys); - protobufTransaction.addCommands(buildCommand(Exists, commandArgs)); return getThis(); } @@ -937,7 +898,6 @@ public T exists(@NonNull String[] keys) { */ public T unlink(@NonNull String[] keys) { ArgsArray commandArgs = buildArgs(keys); - protobufTransaction.addCommands(buildCommand(Unlink, commandArgs)); return getThis(); } @@ -960,7 +920,6 @@ public T unlink(@NonNull String[] keys) { */ public T expire(@NonNull String key, long seconds) { ArgsArray commandArgs = buildArgs(key, Long.toString(seconds)); - protobufTransaction.addCommands(buildCommand(Expire, commandArgs)); return getThis(); } @@ -1010,7 +969,6 @@ public T expire(@NonNull String key, long seconds, @NonNull ExpireOptions expire */ public T expireAt(@NonNull String key, long unixSeconds) { ArgsArray commandArgs = buildArgs(key, Long.toString(unixSeconds)); - protobufTransaction.addCommands(buildCommand(ExpireAt, commandArgs)); return getThis(); } @@ -1061,7 +1019,6 @@ public T expireAt(@NonNull String key, long unixSeconds, @NonNull ExpireOptions */ public T pexpire(@NonNull String key, long milliseconds) { ArgsArray commandArgs = buildArgs(key, Long.toString(milliseconds)); - protobufTransaction.addCommands(buildCommand(PExpire, commandArgs)); return getThis(); } @@ -1253,7 +1210,7 @@ public T zadd( @NonNull String key, @NonNull Map membersScoresMap, @NonNull ZaddOptions options) { - return getThis().zadd(key, membersScoresMap, options, false); + return zadd(key, membersScoresMap, options, false); } /** @@ -1270,7 +1227,7 @@ public T zadd( */ public T zadd( @NonNull String key, @NonNull Map membersScoresMap, boolean changed) { - return getThis().zadd(key, membersScoresMap, ZaddOptions.builder().build(), changed); + return zadd(key, membersScoresMap, ZaddOptions.builder().build(), changed); } /** @@ -1283,7 +1240,7 @@ public T zadd( * @return Command Response - The number of elements added to the sorted set. */ public T zadd(@NonNull String key, @NonNull Map membersScoresMap) { - return getThis().zadd(key, membersScoresMap, ZaddOptions.builder().build(), false); + return zadd(key, membersScoresMap, ZaddOptions.builder().build(), false); } /** @@ -1331,7 +1288,7 @@ public T zaddIncr( * @return Command Response - The score of the member. */ public T zaddIncr(@NonNull String key, @NonNull String member, double increment) { - return getThis().zaddIncr(key, member, increment, ZaddOptions.builder().build()); + return zaddIncr(key, member, increment, ZaddOptions.builder().build()); } /** @@ -1362,7 +1319,7 @@ public T zrem(@NonNull String key, @NonNull String[] members) { * return 0. */ public T zcard(@NonNull String key) { - ArgsArray commandArgs = buildArgs(new String[] {key}); + ArgsArray commandArgs = buildArgs(key); protobufTransaction.addCommands(buildCommand(Zcard, commandArgs)); return getThis(); } @@ -1382,7 +1339,7 @@ public T zcard(@NonNull String key) { * command returns an empty Map. */ public T zpopmin(@NonNull String key, long count) { - ArgsArray commandArgs = buildArgs(new String[] {key, Long.toString(count)}); + ArgsArray commandArgs = buildArgs(key, Long.toString(count)); protobufTransaction.addCommands(buildCommand(ZPopMin, commandArgs)); return getThis(); } @@ -1398,7 +1355,7 @@ public T zpopmin(@NonNull String key, long count) { * command returns an empty Map. */ public T zpopmin(@NonNull String key) { - ArgsArray commandArgs = buildArgs(new String[] {key}); + ArgsArray commandArgs = buildArgs(key); protobufTransaction.addCommands(buildCommand(ZPopMin, commandArgs)); return getThis(); } @@ -1418,7 +1375,7 @@ public T zpopmin(@NonNull String key) { * command returns an empty Map. */ public T zpopmax(@NonNull String key, long count) { - ArgsArray commandArgs = buildArgs(new String[] {key, Long.toString(count)}); + ArgsArray commandArgs = buildArgs(key, Long.toString(count)); protobufTransaction.addCommands(buildCommand(ZPopMax, commandArgs)); return getThis(); } @@ -1434,7 +1391,7 @@ public T zpopmax(@NonNull String key, long count) { * command returns an empty Map. */ public T zpopmax(@NonNull String key) { - ArgsArray commandArgs = buildArgs(new String[] {key}); + ArgsArray commandArgs = buildArgs(key); protobufTransaction.addCommands(buildCommand(ZPopMax, commandArgs)); return getThis(); } @@ -1450,7 +1407,7 @@ public T zpopmax(@NonNull String key) { * If key does not exist, null is returned. */ public T zscore(@NonNull String key, @NonNull String member) { - ArgsArray commandArgs = buildArgs(new String[] {key, member}); + ArgsArray commandArgs = buildArgs(key, member); protobufTransaction.addCommands(buildCommand(ZScore, commandArgs)); return getThis(); } @@ -1458,7 +1415,7 @@ public T zscore(@NonNull String key, @NonNull String member) { /** * Returns the rank of member in the sorted set stored at key, with * scores ordered from low to high.
- * To get the rank of member with it's score, see zrankWithScore. + * To get the rank of member with its score, see {@link #zrankWithScore}. * * @see redis.io for more details. * @param key The key of the sorted set. @@ -1468,13 +1425,13 @@ public T zscore(@NonNull String key, @NonNull String member) { * null will be returned. */ public T zrank(@NonNull String key, @NonNull String member) { - ArgsArray commandArgs = buildArgs(new String[] {key, member}); + ArgsArray commandArgs = buildArgs(key, member); protobufTransaction.addCommands(buildCommand(Zrank, commandArgs)); return getThis(); } /** - * Returns the rank of member in the sorted set stored at key with it's + * Returns the rank of member in the sorted set stored at key with its * score, where scores are ordered from the lowest to highest. * * @see redis.io for more details. @@ -1486,7 +1443,7 @@ public T zrank(@NonNull String key, @NonNull String member) { * null will be returned. */ public T zrankWithScore(@NonNull String key, @NonNull String member) { - ArgsArray commandArgs = buildArgs(new String[] {key, member, WITH_SCORE_REDIS_API}); + ArgsArray commandArgs = buildArgs(key, member, WITH_SCORE_REDIS_API); protobufTransaction.addCommands(buildCommand(Zrank, commandArgs)); return getThis(); } @@ -1500,8 +1457,7 @@ public T zrankWithScore(@NonNull String key, @NonNull String member) { * @return Command Response - The id of the added entry. */ public T xadd(@NonNull String key, @NonNull Map values) { - this.xadd(key, values, StreamAddOptions.builder().build()); - return getThis(); + return xadd(key, values, StreamAddOptions.builder().build()); } /** @@ -1535,7 +1491,6 @@ public T xadd( */ public T pttl(@NonNull String key) { ArgsArray commandArgs = buildArgs(key); - protobufTransaction.addCommands(buildCommand(PTTL, commandArgs)); return getThis(); } @@ -1551,7 +1506,7 @@ public T pttl(@NonNull String key) { * have an associated timeout, true if the timeout has been removed. */ public T persist(@NonNull String key) { - ArgsArray commandArgs = buildArgs(new String[] {key}); + ArgsArray commandArgs = buildArgs(key); protobufTransaction.addCommands(buildCommand(Persist, commandArgs)); return getThis(); }