Skip to content

Commit d019ada

Browse files
Polishing.
Fix indention, variable names and add missing author tags. Original Pull Request: #2097
1 parent 38d3576 commit d019ada

File tree

6 files changed

+69
-37
lines changed

6 files changed

+69
-37
lines changed

src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package org.springframework.data.redis.connection;
1717

18+
import java.nio.charset.StandardCharsets;
19+
1820
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
1921
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
2022
import org.springframework.util.ObjectUtils;
@@ -23,6 +25,8 @@
2325
* Default implementation for {@link StringTuple} interface.
2426
*
2527
* @author Costin Leau
28+
* @author Mark Paluch
29+
* @author Christoph Strobl
2630
*/
2731
public class DefaultStringTuple extends DefaultTuple implements StringTuple {
2832

@@ -35,6 +39,7 @@ public class DefaultStringTuple extends DefaultTuple implements StringTuple {
3539
* @param score
3640
*/
3741
public DefaultStringTuple(byte[] value, String valueAsString, Double score) {
42+
3843
super(value, score);
3944
this.valueAsString = valueAsString;
4045

@@ -43,13 +48,12 @@ public DefaultStringTuple(byte[] value, String valueAsString, Double score) {
4348
/**
4449
* Constructs a new <code>DefaultStringTuple</code> instance.
4550
*
46-
* @param valueAsString
51+
* @param valueAsString must not be {@literal null}.
4752
* @param score
4853
* @since 2.6
4954
*/
5055
public DefaultStringTuple(String valueAsString, double score) {
51-
super(valueAsString.getBytes(), score);
52-
this.valueAsString = valueAsString;
56+
this(valueAsString.getBytes(StandardCharsets.UTF_8), valueAsString, score);
5357
}
5458

5559
/**
@@ -59,6 +63,7 @@ public DefaultStringTuple(String valueAsString, double score) {
5963
* @param valueAsString
6064
*/
6165
public DefaultStringTuple(Tuple tuple, String valueAsString) {
66+
6267
super(tuple.getValue(), tuple.getScore());
6368
this.valueAsString = valueAsString;
6469
}

src/main/java/org/springframework/data/redis/core/ZSetOperations.java

+33-33
Original file line numberDiff line numberDiff line change
@@ -916,38 +916,38 @@ default Set<V> rangeByLex(K key, Range range) {
916916
@Nullable
917917
Set<V> rangeByLex(K key, Range range, Limit limit);
918918

919-
/**
920-
* Get all elements with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value between
921-
* {@link Range#getMin()} and {@link Range#getMax()}.
922-
*
923-
* @param key must not be {@literal null}.
924-
* @param range must not be {@literal null}.
925-
* @return {@literal null} when used in pipeline / transaction.
926-
* @since 2.4
927-
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
928-
*/
929-
@Nullable
930-
default Set<V> reverseRangeByLex(K key, Range range) {
931-
return reverseRangeByLex(key, range, Limit.unlimited());
932-
}
919+
/**
920+
* Get all elements with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value between
921+
* {@link Range#getMin()} and {@link Range#getMax()}.
922+
*
923+
* @param key must not be {@literal null}.
924+
* @param range must not be {@literal null}.
925+
* @return {@literal null} when used in pipeline / transaction.
926+
* @since 2.4
927+
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
928+
*/
929+
@Nullable
930+
default Set<V> reverseRangeByLex(K key, Range range) {
931+
return reverseRangeByLex(key, range, Limit.unlimited());
932+
}
933933

934-
/**
935-
* Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at
936-
* {@link Limit#getOffset()} with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value
937-
* between {@link Range#getMin()} and {@link Range#getMax()}.
938-
*
939-
* @param key must not be {@literal null}
940-
* @param range must not be {@literal null}.
941-
* @param limit can be {@literal null}.
942-
* @return {@literal null} when used in pipeline / transaction.
943-
* @since 2.4
944-
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
945-
*/
946-
@Nullable
947-
Set<V> reverseRangeByLex(K key, Range range, Limit limit);
934+
/**
935+
* Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at
936+
* {@link Limit#getOffset()} with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value
937+
* between {@link Range#getMin()} and {@link Range#getMax()}.
938+
*
939+
* @param key must not be {@literal null}
940+
* @param range must not be {@literal null}.
941+
* @param limit can be {@literal null}.
942+
* @return {@literal null} when used in pipeline / transaction.
943+
* @since 2.4
944+
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
945+
*/
946+
@Nullable
947+
Set<V> reverseRangeByLex(K key, Range range, Limit limit);
948948

949-
/**
950-
* @return never {@literal null}.
951-
*/
952-
RedisOperations<K, V> getOperations();
953-
}
949+
/**
950+
* @return never {@literal null}.
951+
*/
952+
RedisOperations<K, V> getOperations();
953+
}

src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static <E> RedisZSet<E> create(String key, RedisOperations<String, E> operations
210210
/**
211211
* Union this set and other {@link RedisZSet}s.
212212
*
213-
* @param set must not be {@literal null}.
213+
* @param sets must not be {@literal null}.
214214
* @return a {@link Set} containing the combined values with their scores.
215215
* @since 2.6
216216
*/

src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java

+22
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,7 @@ void zPopMax() {
18781878

18791879
@Test
18801880
void testZIncrBy() {
1881+
18811882
actual.add(connection.zAdd("myset", 2, "Bob"));
18821883
actual.add(connection.zAdd("myset", 1, "James"));
18831884
actual.add(connection.zAdd("myset", 4, "Joe"));
@@ -1890,6 +1891,7 @@ void testZIncrBy() {
18901891
@Test // GH-2041
18911892
@EnabledOnCommand("ZDIFF")
18921893
void testZDiff() {
1894+
18931895
actual.add(connection.zAdd("myset", 2, "Bob"));
18941896
actual.add(connection.zAdd("myset", 1, "James"));
18951897
actual.add(connection.zAdd("myset", 4, "Joe"));
@@ -1904,6 +1906,7 @@ void testZDiff() {
19041906
@Test // GH-2041
19051907
@EnabledOnCommand("ZDIFFSTORE")
19061908
void testZDiffStore() {
1909+
19071910
actual.add(connection.zAdd("myset", 2, "Bob"));
19081911
actual.add(connection.zAdd("myset", 1, "James"));
19091912
actual.add(connection.zAdd("myset", 4, "Joe"));
@@ -1917,6 +1920,7 @@ void testZDiffStore() {
19171920
@Test // GH-2042
19181921
@EnabledOnCommand("ZINTER")
19191922
void testZInter() {
1923+
19201924
actual.add(connection.zAdd("myset", 2, "Bob"));
19211925
actual.add(connection.zAdd("myset", 1, "James"));
19221926
actual.add(connection.zAdd("myset", 4, "Joe"));
@@ -1932,6 +1936,7 @@ void testZInter() {
19321936
@Test // GH-2042
19331937
@EnabledOnCommand("ZINTER")
19341938
void testZInterAggWeights() {
1939+
19351940
actual.add(connection.zAdd("myset", 2, "Bob"));
19361941
actual.add(connection.zAdd("myset", 1, "James"));
19371942
actual.add(connection.zAdd("myset", 4, "Joe"));
@@ -1947,6 +1952,7 @@ void testZInterAggWeights() {
19471952

19481953
@Test
19491954
void testZInterStore() {
1955+
19501956
actual.add(connection.zAdd("myset", 2, "Bob"));
19511957
actual.add(connection.zAdd("myset", 1, "James"));
19521958
actual.add(connection.zAdd("myset", 4, "Joe"));
@@ -1960,6 +1966,7 @@ void testZInterStore() {
19601966

19611967
@Test
19621968
void testZInterStoreAggWeights() {
1969+
19631970
actual.add(connection.zAdd("myset", 2, "Bob"));
19641971
actual.add(connection.zAdd("myset", 1, "James"));
19651972
actual.add(connection.zAdd("myset", 4, "Joe"));
@@ -1975,6 +1982,7 @@ void testZInterStoreAggWeights() {
19751982

19761983
@Test
19771984
void testZRangeWithScores() {
1985+
19781986
actual.add(connection.zAdd("myset", 2, "Bob"));
19791987
actual.add(connection.zAdd("myset", 1, "James"));
19801988
actual.add(connection.zRangeWithScores("myset", 0, -1));
@@ -1985,6 +1993,7 @@ void testZRangeWithScores() {
19851993

19861994
@Test
19871995
void testZRangeByScore() {
1996+
19881997
actual.add(connection.zAdd("myset", 2, "Bob"));
19891998
actual.add(connection.zAdd("myset", 1, "James"));
19901999
actual.add(connection.zRangeByScore("myset", 1, 1));
@@ -1993,6 +2002,7 @@ void testZRangeByScore() {
19932002

19942003
@Test
19952004
void testZRangeByScoreOffsetCount() {
2005+
19962006
actual.add(connection.zAdd("myset", 2, "Bob"));
19972007
actual.add(connection.zAdd("myset", 1, "James"));
19982008
actual.add(connection.zRangeByScore("myset", 1d, 3d, 1, -1));
@@ -2001,6 +2011,7 @@ void testZRangeByScoreOffsetCount() {
20012011

20022012
@Test
20032013
void testZRangeByScoreWithScores() {
2014+
20042015
actual.add(connection.zAdd("myset", 2, "Bob"));
20052016
actual.add(connection.zAdd("myset", 1, "James"));
20062017
actual.add(connection.zRangeByScoreWithScores("myset", 2d, 5d));
@@ -2010,6 +2021,7 @@ void testZRangeByScoreWithScores() {
20102021

20112022
@Test
20122023
void testZRangeByScoreWithScoresOffsetCount() {
2024+
20132025
actual.add(connection.zAdd("myset", 2, "Bob"));
20142026
actual.add(connection.zAdd("myset", 1, "James"));
20152027
actual.add(connection.zRangeByScoreWithScores("myset", 1d, 5d, 0, 1));
@@ -2019,6 +2031,7 @@ void testZRangeByScoreWithScoresOffsetCount() {
20192031

20202032
@Test
20212033
void testZRevRange() {
2034+
20222035
actual.add(connection.zAdd("myset", 2, "Bob"));
20232036
actual.add(connection.zAdd("myset", 1, "James"));
20242037
actual.add(connection.zRevRange("myset", 0, -1));
@@ -2027,6 +2040,7 @@ void testZRevRange() {
20272040

20282041
@Test
20292042
void testZRevRangeWithScores() {
2043+
20302044
actual.add(connection.zAdd("myset", 2, "Bob"));
20312045
actual.add(connection.zAdd("myset", 1, "James"));
20322046
actual.add(connection.zRevRangeWithScores("myset", 0, -1));
@@ -2037,6 +2051,7 @@ void testZRevRangeWithScores() {
20372051

20382052
@Test
20392053
void testZRevRangeByScoreOffsetCount() {
2054+
20402055
actual.add(connection.zAdd("myset".getBytes(), 2, "Bob".getBytes()));
20412056
actual.add(connection.zAdd("myset".getBytes(), 1, "James".getBytes()));
20422057
actual.add(connection.zRevRangeByScore("myset", 0d, 3d, 0, 5));
@@ -2045,6 +2060,7 @@ void testZRevRangeByScoreOffsetCount() {
20452060

20462061
@Test
20472062
void testZRevRangeByScore() {
2063+
20482064
actual.add(connection.zAdd("myset".getBytes(), 2, "Bob".getBytes()));
20492065
actual.add(connection.zAdd("myset".getBytes(), 1, "James".getBytes()));
20502066
actual.add(connection.zRevRangeByScore("myset", 0d, 3d));
@@ -2053,6 +2069,7 @@ void testZRevRangeByScore() {
20532069

20542070
@Test
20552071
void testZRevRangeByScoreWithScoresOffsetCount() {
2072+
20562073
actual.add(connection.zAdd("myset".getBytes(), 2, "Bob".getBytes()));
20572074
actual.add(connection.zAdd("myset".getBytes(), 1, "James".getBytes()));
20582075
actual.add(connection.zRevRangeByScoreWithScores("myset", 0d, 3d, 0, 1));
@@ -2062,6 +2079,7 @@ void testZRevRangeByScoreWithScoresOffsetCount() {
20622079

20632080
@Test
20642081
void testZRevRangeByScoreWithScores() {
2082+
20652083
actual.add(connection.zAdd("myset", 2, "Bob"));
20662084
actual.add(connection.zAdd("myset", 1, "James"));
20672085
actual.add(connection.zAdd("myset", 3, "Joe"));
@@ -2073,6 +2091,7 @@ void testZRevRangeByScoreWithScores() {
20732091

20742092
@Test
20752093
void testZRank() {
2094+
20762095
actual.add(connection.zAdd("myset", 2, "Bob"));
20772096
actual.add(connection.zAdd("myset", 1, "James"));
20782097
actual.add(connection.zRank("myset", "James"));
@@ -2082,6 +2101,7 @@ void testZRank() {
20822101

20832102
@Test
20842103
void testZRem() {
2104+
20852105
actual.add(connection.zAdd("myset", 2, "Bob"));
20862106
actual.add(connection.zAdd("myset", 1, "James"));
20872107
actual.add(connection.zRem("myset", "James"));
@@ -2091,6 +2111,7 @@ void testZRem() {
20912111

20922112
@Test
20932113
void testZRemMultiple() {
2114+
20942115
actual.add(connection.zAdd("myset", 2, "Bob"));
20952116
actual.add(connection.zAdd("myset", 1, "James"));
20962117
actual.add(connection.zAdd("myset", 0.5, "Joe"));
@@ -2103,6 +2124,7 @@ void testZRemMultiple() {
21032124

21042125
@Test
21052126
void testZRemRangeByRank() {
2127+
21062128
actual.add(connection.zAdd("myset", 2, "Bob"));
21072129
actual.add(connection.zAdd("myset", 1, "James"));
21082130
actual.add(connection.zRemRange("myset", 0L, 3L));

src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,7 @@ public void zIncrByShouldIncScoreForValueCorrectly() {
20082008

20092009
@Test // GH-2041
20102010
public void zDiffShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
2011+
20112012
assertThatExceptionOfType(DataAccessException.class)
20122013
.isThrownBy(() -> clusterConnection.zDiff(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
20132014
assertThatExceptionOfType(DataAccessException.class)
@@ -2046,6 +2047,7 @@ public void zDiffStoreShouldWorkForSameSlotKeys() {
20462047

20472048
@Test // GH-2042
20482049
public void zInterShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
2050+
20492051
assertThatExceptionOfType(DataAccessException.class)
20502052
.isThrownBy(() -> clusterConnection.zInter(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
20512053
assertThatExceptionOfType(DataAccessException.class)
@@ -2068,6 +2070,7 @@ public void zInterShouldWorkForSameSlotKeys() {
20682070

20692071
@Test // GH-2042
20702072
public void zInterStoreShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
2073+
20712074
assertThatExceptionOfType(DataAccessException.class)
20722075
.isThrownBy(() -> clusterConnection.zInterStore(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
20732076
}

src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,7 @@ public void zIncrByShouldIncScoreForValueCorrectly() {
20492049

20502050
@Test // GH-2041
20512051
public void zDiffShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
2052+
20522053
assertThatExceptionOfType(DataAccessException.class)
20532054
.isThrownBy(() -> clusterConnection.zDiff(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
20542055
assertThatExceptionOfType(DataAccessException.class)
@@ -2087,6 +2088,7 @@ public void zDiffStoreShouldWorkForSameSlotKeys() {
20872088

20882089
@Test // GH-2042
20892090
public void zInterShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
2091+
20902092
assertThatExceptionOfType(DataAccessException.class)
20912093
.isThrownBy(() -> clusterConnection.zInter(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
20922094
assertThatExceptionOfType(DataAccessException.class)

0 commit comments

Comments
 (0)