From aa02dd07989b578a266c5e9a3ba2b406d3f0fce4 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 15 Sep 2020 10:01:02 +0200 Subject: [PATCH] Rename LPOS FIRST option to RANK #1410 The FIRST option was renamed in Redis so we're following now. --- src/main/java/io/lettuce/core/LPosArgs.java | 24 +++++++++---------- .../commands/ListCommandIntegrationTests.java | 7 +++--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/lettuce/core/LPosArgs.java b/src/main/java/io/lettuce/core/LPosArgs.java index 0d939bba96..9c265cbfca 100644 --- a/src/main/java/io/lettuce/core/LPosArgs.java +++ b/src/main/java/io/lettuce/core/LPosArgs.java @@ -30,7 +30,7 @@ */ public class LPosArgs implements CompositeArgument { - private Long first; + private Long rank; private Long maxlen; @@ -66,13 +66,13 @@ public static LPosArgs maxlen(long count) { } /** - * Creates new {@link LPosArgs} and setting {@literal FIRST}. + * Creates new {@link LPosArgs} and setting {@literal RANK}. * - * @return new {@link LPosArgs} with {@literal FIRST} set. - * @see LPosArgs#maxlen(long) + * @return new {@link LPosArgs} with {@literal RANK} set. + * @see LPosArgs#rank(long) */ - public static LPosArgs first(long rank) { - return new LPosArgs().first(rank); + public static LPosArgs rank(long rank) { + return new LPosArgs().rank(rank); } } @@ -92,14 +92,14 @@ public LPosArgs maxlen(long maxlen) { } /** - * Specify the rank of the first element to return, in case there are multiple matches + * Specify the rank of the first element to return, in case there are multiple matches. * * @param rank number. * @return {@code this} */ - public LPosArgs first(long rank) { + public LPosArgs rank(long rank) { - this.first = rank; + this.rank = rank; return this; } @@ -112,9 +112,9 @@ public void build(CommandArgs args) { args.add(maxlen); } - if (first != null) { - args.add("FIRST"); - args.add(first); + if (rank != null) { + args.add("RANK"); + args.add(rank); } } diff --git a/src/test/java/io/lettuce/core/commands/ListCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/ListCommandIntegrationTests.java index f98cc5fc5e..f81ac614c0 100644 --- a/src/test/java/io/lettuce/core/commands/ListCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/ListCommandIntegrationTests.java @@ -20,7 +20,6 @@ import java.time.Duration; import java.util.List; -import java.util.concurrent.TimeUnit; import javax.inject.Inject; @@ -125,9 +124,9 @@ void lpos() { assertThat(redis.lpos(key, "a")).isEqualTo(0); assertThat(redis.lpos(key, "c")).isEqualTo(2); - assertThat(redis.lpos(key, "c", LPosArgs.Builder.first(1))).isEqualTo(2); - assertThat(redis.lpos(key, "c", LPosArgs.Builder.first(2))).isEqualTo(6); - assertThat(redis.lpos(key, "c", LPosArgs.Builder.first(4))).isNull(); + assertThat(redis.lpos(key, "c", LPosArgs.Builder.rank(1))).isEqualTo(2); + assertThat(redis.lpos(key, "c", LPosArgs.Builder.rank(2))).isEqualTo(6); + assertThat(redis.lpos(key, "c", LPosArgs.Builder.rank(4))).isNull(); assertThat(redis.lpos(key, "c", 0)).contains(2L, 6L, 7L); assertThat(redis.lpos(key, "c", 0, LPosArgs.Builder.maxlen(1))).isEmpty();