@@ -70,7 +70,7 @@ private Builder() {
70
70
* Create a new {@code GET} subcommand.
71
71
*
72
72
* @param bitFieldType the bit field type, must not be {@code null}.
73
- * @param offset bitfield offset
73
+ * @param offset bitfield offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}.
74
74
* @return a new {@code GET} subcommand for the given {@code bitFieldType} and {@code offset}.
75
75
*/
76
76
public static BitFieldArgs get (BitFieldType bitFieldType , int offset ) {
@@ -93,7 +93,7 @@ public static BitFieldArgs get(BitFieldType bitFieldType, Offset offset) {
93
93
* Create a new {@code SET} subcommand.
94
94
*
95
95
* @param bitFieldType the bit field type, must not be {@code null}.
96
- * @param offset bitfield offset
96
+ * @param offset bitfield offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}.
97
97
* @param value the value
98
98
* @return a new {@code SET} subcommand for the given {@code bitFieldType}, {@code offset} and {@code value}.
99
99
*/
@@ -118,7 +118,7 @@ public static BitFieldArgs set(BitFieldType bitFieldType, Offset offset, long va
118
118
* Create a new {@code INCRBY} subcommand.
119
119
*
120
120
* @param bitFieldType the bit field type, must not be {@code null}.
121
- * @param offset bitfield offset
121
+ * @param offset bitfield offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}.
122
122
* @param value the value
123
123
* @return a new {@code INCRBY} subcommand for the given {@code bitFieldType}, {@code offset} and {@code value} .
124
124
*/
@@ -177,7 +177,7 @@ public static BitFieldType unsigned(int bits) {
177
177
/**
178
178
* Creates a new {@link Offset} for the given {@code offset}.
179
179
*
180
- * @param offset zero-based offset.
180
+ * @param offset zero-based offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)} .
181
181
* @return the {@link Offset}.
182
182
* @since 4.3
183
183
*/
@@ -233,7 +233,7 @@ public BitFieldArgs get(BitFieldType bitFieldType) {
233
233
* Adds a new {@code GET} subcommand.
234
234
*
235
235
* @param bitFieldType the bit field type, must not be {@code null}.
236
- * @param offset bitfield offset
236
+ * @param offset bitfield offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}.
237
237
* @return a new {@code GET} subcommand for the given {@code bitFieldType} and {@code offset}.
238
238
*/
239
239
public BitFieldArgs get (BitFieldType bitFieldType , int offset ) {
@@ -258,7 +258,7 @@ public BitFieldArgs get(BitFieldType bitFieldType, Offset offset) {
258
258
/**
259
259
* Adds a new {@code GET} subcommand using the field type of the previous command.
260
260
*
261
- * @param offset bitfield offset
261
+ * @param offset bitfield offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}.
262
262
* @return a new {@code GET} subcommand for the given {@code bitFieldType} and {@code offset}.
263
263
* @throws IllegalStateException if no previous field type was found
264
264
*/
@@ -291,7 +291,7 @@ public BitFieldArgs set(BitFieldType bitFieldType, long value) {
291
291
/**
292
292
* Adds a new {@code SET} subcommand using the field type of the previous command.
293
293
*
294
- * @param offset bitfield offset
294
+ * @param offset bitfield offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}.
295
295
* @param value the value
296
296
* @return a new {@code SET} subcommand for the given {@code bitFieldType}, {@code offset} and {@code value}.
297
297
* @throws IllegalStateException if no previous field type was found
@@ -304,7 +304,7 @@ public BitFieldArgs set(int offset, long value) {
304
304
* Adds a new {@code SET} subcommand.
305
305
*
306
306
* @param bitFieldType the bit field type, must not be {@code null}.
307
- * @param offset bitfield offset
307
+ * @param offset bitfield offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}.
308
308
* @param value the value
309
309
* @return a new {@code SET} subcommand for the given {@code bitFieldType}, {@code offset} and {@code value}.
310
310
*/
@@ -353,7 +353,7 @@ public BitFieldArgs incrBy(BitFieldType bitFieldType, long value) {
353
353
/**
354
354
* Adds a new {@code INCRBY} subcommand using the field type of the previous command.
355
355
*
356
- * @param offset bitfield offset
356
+ * @param offset bitfield offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}.
357
357
* @param value the value
358
358
* @return a new {@code INCRBY} subcommand for the given {@code bitFieldType}, {@code offset} and {@code value}.
359
359
* @throws IllegalStateException if no previous field type was found
@@ -366,7 +366,7 @@ public BitFieldArgs incrBy(int offset, long value) {
366
366
* Adds a new {@code INCRBY} subcommand.
367
367
*
368
368
* @param bitFieldType the bit field type, must not be {@code null}.
369
- * @param offset bitfield offset
369
+ * @param offset bitfield offset, supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}.
370
370
* @param value the value
371
371
* @return a new {@code INCRBY} subcommand for the given {@code bitFieldType}, {@code offset} and {@code value}.
372
372
*/
@@ -432,14 +432,13 @@ private static class Set extends SubCommand {
432
432
433
433
private final boolean bitOffset ;
434
434
435
- private final long offset ;
435
+ private final int offset ;
436
436
437
437
private final long value ;
438
438
439
439
private Set (BitFieldType bitFieldType , boolean bitOffset , int offset , long value ) {
440
440
441
441
LettuceAssert .notNull (bitFieldType , "BitFieldType must not be null" );
442
- LettuceAssert .isTrue (offset > -1 , "Offset must be greater or equal to 0" );
443
442
444
443
this .bitFieldType = bitFieldType ;
445
444
this .bitOffset = bitOffset ;
@@ -453,9 +452,9 @@ <K, V> void build(CommandArgs<K, V> args) {
453
452
args .add (CommandType .SET ).add (bitFieldType .asString ());
454
453
455
454
if (bitOffset ) {
456
- args .add ("#" + offset );
455
+ args .add ("#" + Integer . toUnsignedString ( offset ) );
457
456
} else {
458
- args .add (offset );
457
+ args .add (Integer . toUnsignedString ( offset ) );
459
458
}
460
459
461
460
args .add (value );
@@ -477,7 +476,6 @@ private static class Get extends SubCommand {
477
476
private Get (BitFieldType bitFieldType , boolean bitOffset , int offset ) {
478
477
479
478
LettuceAssert .notNull (bitFieldType , "BitFieldType must not be null" );
480
- LettuceAssert .isTrue (offset > -1 , "Offset must be greater or equal to 0" );
481
479
482
480
this .bitFieldType = bitFieldType ;
483
481
this .bitOffset = bitOffset ;
@@ -490,9 +488,9 @@ <K, V> void build(CommandArgs<K, V> args) {
490
488
args .add (CommandType .GET ).add (bitFieldType .asString ());
491
489
492
490
if (bitOffset ) {
493
- args .add ("#" + offset );
491
+ args .add ("#" + Integer . toUnsignedString ( offset ) );
494
492
} else {
495
- args .add (offset );
493
+ args .add (Integer . toUnsignedString ( offset ) );
496
494
}
497
495
}
498
496
@@ -507,14 +505,13 @@ private static class IncrBy extends SubCommand {
507
505
508
506
private final boolean bitOffset ;
509
507
510
- private final long offset ;
508
+ private final int offset ;
511
509
512
510
private final long value ;
513
511
514
512
private IncrBy (BitFieldType bitFieldType , boolean offsetWidthMultiplier , int offset , long value ) {
515
513
516
514
LettuceAssert .notNull (bitFieldType , "BitFieldType must not be null" );
517
- LettuceAssert .isTrue (offset > -1 , "Offset must be greater or equal to 0" );
518
515
519
516
this .bitFieldType = bitFieldType ;
520
517
this .bitOffset = offsetWidthMultiplier ;
@@ -528,9 +525,9 @@ <K, V> void build(CommandArgs<K, V> args) {
528
525
args .add (CommandType .INCRBY ).add (bitFieldType .asString ());
529
526
530
527
if (bitOffset ) {
531
- args .add ("#" + offset );
528
+ args .add ("#" + Integer . toUnsignedString ( offset ) );
532
529
} else {
533
- args .add (offset );
530
+ args .add (Integer . toUnsignedString ( offset ) );
534
531
}
535
532
536
533
args .add (value );
@@ -646,8 +643,8 @@ public String toString() {
646
643
}
647
644
648
645
/**
649
- * Represents a bit field offset. See also <a href="https://redis.io/commands/bitfield#bits-and-positional-offsets">Bits and
650
- * positional offsets</a>
646
+ * Represents a bit field offset. Offset supports up to {@code 2^32-1} using {@link Integer#toUnsignedString(int)}. See also
647
+ * <a href="https://redis.io/commands/bitfield#bits-and-positional-offsets">Bits and positional offsets</a>
651
648
*
652
649
* @since 4.3
653
650
*/
@@ -681,7 +678,7 @@ public int getOffset() {
681
678
682
679
@ Override
683
680
public String toString () {
684
- return (multiplyByTypeWidth ? "#" : "" ) + offset ;
681
+ return (multiplyByTypeWidth ? "#" : "" ) + Integer . toUnsignedString ( offset ) ;
685
682
}
686
683
687
684
}
0 commit comments