Skip to content

Commit 7118324

Browse files
committed
Polish enhanced switch statements.
See #2705 Original pull request: #2706
1 parent e34872d commit 7118324

14 files changed

+643
-556
lines changed

src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java

+105-77
Large diffs are not rendered by default.

src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java

+9-44
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
* @author Ninad Divadkar
9999
* @author Guy Korland
100100
* @author dengliming
101+
* @author John Blum
101102
*/
102103
@SuppressWarnings("ConstantConditions")
103104
abstract class JedisConverters extends Converters {
@@ -122,7 +123,6 @@ public static Converter<String, byte[]> stringToBytes() {
122123
/**
123124
* {@link ListConverter} converting jedis {@link redis.clients.jedis.resps.Tuple} to {@link Tuple}.
124125
*
125-
* @return
126126
* @since 1.4
127127
*/
128128
static ListConverter<redis.clients.jedis.resps.Tuple, Tuple> tuplesToTuples() {
@@ -145,7 +145,6 @@ public static Tuple toTuple(redis.clients.jedis.resps.Tuple source) {
145145
* Map a {@link Set} of {@link Tuple} by {@code value} to its {@code score}.
146146
*
147147
* @param tuples must not be {@literal null}.
148-
* @return
149148
* @since 2.0
150149
*/
151150
public static Map<byte[], Double> toTupleMap(Set<Tuple> tuples) {
@@ -170,8 +169,6 @@ public static byte[] toBytes(Long source) {
170169
}
171170

172171
/**
173-
* @param source
174-
* @return
175172
* @since 1.6
176173
*/
177174
public static byte[] toBytes(Double source) {
@@ -204,24 +201,23 @@ public static ValueEncoding toEncoding(byte[] source) {
204201
}
205202

206203
/**
207-
* @param source
208-
* @return
209204
* @since 1.7
210205
*/
211206
@SuppressWarnings("unchecked")
212207
public static RedisClusterNode toNode(Object source) {
213208

214209
List<Object> values = (List<Object>) source;
210+
215211
RedisClusterNode.SlotRange range = new RedisClusterNode.SlotRange(((Number) values.get(0)).intValue(),
216212
((Number) values.get(1)).intValue());
213+
217214
List<Object> nodeInfo = (List<Object>) values.get(2);
215+
218216
return new RedisClusterNode(toString((byte[]) nodeInfo.get(0)), ((Number) nodeInfo.get(1)).intValue(), range);
219217

220218
}
221219

222220
/**
223-
* @param source
224-
* @return
225221
* @since 1.3
226222
*/
227223
public static List<RedisClientInfo> toListOfRedisClientInformation(String source) {
@@ -234,8 +230,6 @@ public static List<RedisClientInfo> toListOfRedisClientInformation(String source
234230
}
235231

236232
/**
237-
* @param source
238-
* @return
239233
* @since 1.4
240234
*/
241235
public static List<RedisServer> toListOfRedisServer(List<Map<String, String>> source) {
@@ -288,6 +282,7 @@ public static SortingParams toSortingParams(@Nullable SortParameters params) {
288282
}
289283

290284
public static BitOP toBitOp(BitOperation bitOp) {
285+
291286
return switch (bitOp) {
292287
case AND -> BitOP.AND;
293288
case OR -> BitOP.OR;
@@ -297,12 +292,9 @@ public static BitOP toBitOp(BitOperation bitOp) {
297292
}
298293

299294
/**
300-
* Converts a given {@link Bound} to its binary representation suitable for {@literal ZRANGEBY*} commands, despite
301-
* {@literal ZRANGEBYLEX}.
295+
* Converts a given {@link org.springframework.data.domain.Range.Bound} to its binary representation suitable for
296+
* {@literal ZRANGEBY*} commands, despite {@literal ZRANGEBYLEX}.
302297
*
303-
* @param boundary
304-
* @param defaultValue
305-
* @return
306298
* @since 1.6
307299
*/
308300
public static byte[] boundaryToBytesForZRange(@Nullable org.springframework.data.domain.Range.Bound<?> boundary,
@@ -316,10 +308,9 @@ public static byte[] boundaryToBytesForZRange(@Nullable org.springframework.data
316308
}
317309

318310
/**
319-
* Converts a given {@link Bound} to its binary representation suitable for ZRANGEBYLEX command.
311+
* Converts a given {@link org.springframework.data.domain.Range.Bound} to its binary representation suitable for
312+
* {@literal ZRANGEBYLEX} command.
320313
*
321-
* @param boundary
322-
* @return
323314
* @since 1.6
324315
*/
325316
public static byte[] boundaryToBytesForZRangeByLex(
@@ -342,7 +333,6 @@ public static byte[] boundaryToBytesForZRangeByLex(
342333
* </dl>
343334
*
344335
* @param expiration must not be {@literal null}.
345-
* @return
346336
* @since 2.2
347337
*/
348338
public static SetParams toSetCommandExPxArgument(Expiration expiration) {
@@ -359,8 +349,6 @@ public static SetParams toSetCommandExPxArgument(Expiration expiration) {
359349
* </dl>
360350
*
361351
* @param expiration must not be {@literal null}.
362-
* @param params
363-
* @return
364352
* @since 2.2
365353
*/
366354
public static SetParams toSetCommandExPxArgument(Expiration expiration, SetParams params) {
@@ -395,7 +383,6 @@ public static SetParams toSetCommandExPxArgument(Expiration expiration, SetParam
395383
* </dl>
396384
*
397385
* @param expiration must not be {@literal null}.
398-
* @return
399386
* @since 2.6
400387
*/
401388
static GetExParams toGetExParams(Expiration expiration) {
@@ -429,7 +416,6 @@ static GetExParams toGetExParams(Expiration expiration) {
429416
* </dl>
430417
*
431418
* @param option must not be {@literal null}.
432-
* @return
433419
* @since 2.2
434420
*/
435421
public static SetParams toSetCommandNxXxArgument(SetOption option) {
@@ -448,8 +434,6 @@ public static SetParams toSetCommandNxXxArgument(SetOption option) {
448434
* </dl>
449435
*
450436
* @param option must not be {@literal null}.
451-
* @param params
452-
* @return
453437
* @since 2.2
454438
*/
455439
public static SetParams toSetCommandNxXxArgument(SetOption option, SetParams params) {
@@ -492,9 +476,6 @@ private static byte[] boundaryToBytes(org.springframework.data.domain.Range.Boun
492476

493477
/**
494478
* Convert {@link ScanOptions} to Jedis {@link ScanParams}.
495-
*
496-
* @param options
497-
* @return
498479
*/
499480
public static ScanParams toScanParams(ScanOptions options) {
500481

@@ -523,8 +504,6 @@ static Long toTime(List<String> source, TimeUnit timeUnit) {
523504
}
524505

525506
/**
526-
* @param source
527-
* @return
528507
* @since 1.8
529508
*/
530509
public static List<String> toStrings(List<byte[]> source) {
@@ -547,15 +526,13 @@ private static <S, T> List<T> toList(Converter<S, T> converter, @Nullable Collec
547526
}
548527

549528
/**
550-
* @return
551529
* @since 1.8
552530
*/
553531
public static ListConverter<redis.clients.jedis.GeoCoordinate, Point> geoCoordinateToPointConverter() {
554532
return new ListConverter<>(JedisConverters::toPoint);
555533
}
556534

557535
/**
558-
* @return
559536
* @since 2.5
560537
*/
561538
@Nullable
@@ -566,8 +543,6 @@ static Point toPoint(@Nullable redis.clients.jedis.GeoCoordinate geoCoordinate)
566543
/**
567544
* Convert {@link Point} into {@link GeoCoordinate}.
568545
*
569-
* @param source
570-
* @return
571546
* @since 1.8
572547
*/
573548
public static GeoCoordinate toGeoCoordinate(Point source) {
@@ -577,8 +552,6 @@ public static GeoCoordinate toGeoCoordinate(Point source) {
577552
/**
578553
* Get a {@link Converter} capable of converting {@link GeoRadiusResponse} into {@link GeoResults}.
579554
*
580-
* @param metric
581-
* @return
582555
* @since 1.8
583556
*/
584557
public static Converter<List<GeoRadiusResponse>, GeoResults<GeoLocation<byte[]>>> geoRadiusResponseToGeoResultsConverter(
@@ -589,8 +562,6 @@ public static Converter<List<GeoRadiusResponse>, GeoResults<GeoLocation<byte[]>>
589562
/**
590563
* Convert {@link Metric} into {@link GeoUnit}.
591564
*
592-
* @param metric
593-
* @return
594565
* @since 1.8
595566
*/
596567
public static GeoUnit toGeoUnit(Metric metric) {
@@ -640,8 +611,6 @@ static ZAddParams toZAddParams(ZAddArgs source) {
640611
/**
641612
* Convert {@link GeoRadiusCommandArgs} into {@link GeoRadiusParam}.
642613
*
643-
* @param source
644-
* @return
645614
* @since 1.8
646615
*/
647616
public static GeoRadiusParam toGeoRadiusParam(GeoRadiusCommandArgs source) {
@@ -677,9 +646,6 @@ public static GeoRadiusParam toGeoRadiusParam(GeoRadiusCommandArgs source) {
677646
/**
678647
* Convert a timeout to seconds using {@code double} representation including fraction of seconds.
679648
*
680-
* @param timeout
681-
* @param unit
682-
* @return
683649
* @since 2.6
684650
*/
685651
static double toSeconds(long timeout, TimeUnit unit) {
@@ -697,7 +663,6 @@ static double toSeconds(long timeout, TimeUnit unit) {
697663
/**
698664
* Convert given {@link BitFieldSubCommands} into argument array.
699665
*
700-
* @param source
701666
* @return never {@literal null}.
702667
* @since 1.8
703668
*/

0 commit comments

Comments
 (0)