Package io.lettuce.core
Class BitFieldArgs
- java.lang.Object
-
- io.lettuce.core.BitFieldArgs
-
- All Implemented Interfaces:
CompositeArgument
public class BitFieldArgs extends Object implements CompositeArgument
Argument list builder for the Redis BITFIELD command.BitFieldArgs
is a mutable object and instances should be used only once to avoid shared mutable state.- Since:
- 4.2
- Author:
- Mark Paluch, Ian Pojman
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BitFieldArgs.BitFieldType
Represents a bit field type with details about signed/unsigned and the number of bits.static class
BitFieldArgs.Builder
Builder entry points forBitFieldArgs
.static class
BitFieldArgs.Offset
Represents a bit field offset.static class
BitFieldArgs.OverflowType
Represents the overflow types for theOVERFLOW
subcommand argument.
-
Constructor Summary
Constructors Constructor Description BitFieldArgs()
Creates a newBitFieldArgs
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <K,V>
voidbuild(CommandArgs<K,V> args)
Build command arguments and contribute arguments toCommandArgs
.BitFieldArgs
get()
Adds a newGET
subcommand using offset0
and the field type of the previous command.BitFieldArgs
get(int offset)
Adds a newGET
subcommand using the field type of the previous command.BitFieldArgs
get(BitFieldArgs.BitFieldType bitFieldType)
Adds a newGET
subcommand using offset0
.BitFieldArgs
get(BitFieldArgs.BitFieldType bitFieldType, int offset)
Adds a newGET
subcommand.BitFieldArgs
get(BitFieldArgs.BitFieldType bitFieldType, BitFieldArgs.Offset offset)
Adds a newGET
subcommand.BitFieldArgs
incrBy(int offset, long value)
Adds a newINCRBY
subcommand using the field type of the previous command.BitFieldArgs
incrBy(long value)
Adds a newINCRBY
subcommand using offset0
and the field type of the previous command.BitFieldArgs
incrBy(BitFieldArgs.BitFieldType bitFieldType, int offset, long value)
Adds a newINCRBY
subcommand.BitFieldArgs
incrBy(BitFieldArgs.BitFieldType bitFieldType, long value)
Adds a newINCRBY
subcommand using offset0
.BitFieldArgs
incrBy(BitFieldArgs.BitFieldType bitFieldType, BitFieldArgs.Offset offset, long value)
Adds a newINCRBY
subcommand.static BitFieldArgs.Offset
offset(int offset)
Creates a newBitFieldArgs.Offset
for the givenoffset
.BitFieldArgs
overflow(BitFieldArgs.OverflowType overflowType)
Adds a newOVERFLOW
subcommand.BitFieldArgs
set(int offset, long value)
Adds a newSET
subcommand using the field type of the previous command.BitFieldArgs
set(long value)
Adds a newSET
subcommand using offset0
and the field type of the previous command.BitFieldArgs
set(BitFieldArgs.BitFieldType bitFieldType, int offset, long value)
Adds a newSET
subcommand.BitFieldArgs
set(BitFieldArgs.BitFieldType bitFieldType, long value)
Adds a newSET
subcommand using offset0
.BitFieldArgs
set(BitFieldArgs.BitFieldType bitFieldType, BitFieldArgs.Offset offset, long value)
Adds a newSET
subcommand.static BitFieldArgs.BitFieldType
signed(int bits)
Creates a new signedBitFieldArgs.BitFieldType
for the given number ofbits
.static BitFieldArgs.Offset
typeWidthBasedOffset(int offset)
Creates a newBitFieldArgs.Offset
for the givenoffset
that is multiplied by the integer type width used in the sub command.static BitFieldArgs.BitFieldType
unsigned(int bits)
Creates a new unsignedBitFieldArgs.BitFieldType
for the given number ofbits
.
-
-
-
Constructor Detail
-
BitFieldArgs
public BitFieldArgs()
Creates a newBitFieldArgs
instance.
-
-
Method Detail
-
signed
public static BitFieldArgs.BitFieldType signed(int bits)
Creates a new signedBitFieldArgs.BitFieldType
for the given number ofbits
. Redis allows up to64
bits for unsigned integers.- Parameters:
bits
- number of bits to define the integer type width.- Returns:
- the
BitFieldArgs.BitFieldType
.
-
unsigned
public static BitFieldArgs.BitFieldType unsigned(int bits)
Creates a new unsignedBitFieldArgs.BitFieldType
for the given number ofbits
. Redis allows up to63
bits for unsigned integers.- Parameters:
bits
- number of bits to define the integer type width.- Returns:
- the
BitFieldArgs.BitFieldType
.
-
offset
public static BitFieldArgs.Offset offset(int offset)
Creates a newBitFieldArgs.Offset
for the givenoffset
.- Parameters:
offset
- zero-based offset.- Returns:
- the
BitFieldArgs.Offset
. - Since:
- 4.3
-
typeWidthBasedOffset
public static BitFieldArgs.Offset typeWidthBasedOffset(int offset)
Creates a newBitFieldArgs.Offset
for the givenoffset
that is multiplied by the integer type width used in the sub command.- Parameters:
offset
- offset to be multiplied by the integer type width.- Returns:
- the
BitFieldArgs.Offset
. - Since:
- 4.3
-
get
public BitFieldArgs get()
Adds a newGET
subcommand using offset0
and the field type of the previous command.- Returns:
- a new
GET
subcommand for the givenbitFieldType
andoffset
. - Throws:
IllegalStateException
- if no previous field type was found
-
get
public BitFieldArgs get(BitFieldArgs.BitFieldType bitFieldType)
Adds a newGET
subcommand using offset0
.- Parameters:
bitFieldType
- the bit field type, must not benull
.- Returns:
- a new
GET
subcommand for the givenbitFieldType
andoffset
.
-
get
public BitFieldArgs get(BitFieldArgs.BitFieldType bitFieldType, int offset)
Adds a newGET
subcommand.- Parameters:
bitFieldType
- the bit field type, must not benull
.offset
- bitfield offset- Returns:
- a new
GET
subcommand for the givenbitFieldType
andoffset
.
-
get
public BitFieldArgs get(BitFieldArgs.BitFieldType bitFieldType, BitFieldArgs.Offset offset)
Adds a newGET
subcommand.- Parameters:
bitFieldType
- the bit field type, must not benull
.offset
- bitfield offset- Returns:
- a new
GET
subcommand for the givenbitFieldType
andoffset
. - Since:
- 4.3
-
get
public BitFieldArgs get(int offset)
Adds a newGET
subcommand using the field type of the previous command.- Parameters:
offset
- bitfield offset- Returns:
- a new
GET
subcommand for the givenbitFieldType
andoffset
. - Throws:
IllegalStateException
- if no previous field type was found
-
set
public BitFieldArgs set(long value)
Adds a newSET
subcommand using offset0
and the field type of the previous command.- Parameters:
value
- the value- Returns:
- a new
SET
subcommand for the givenbitFieldType
,offset
andvalue
. - Throws:
IllegalStateException
- if no previous field type was found
-
set
public BitFieldArgs set(BitFieldArgs.BitFieldType bitFieldType, long value)
Adds a newSET
subcommand using offset0
.- Parameters:
bitFieldType
- the bit field type, must not benull
.value
- the value- Returns:
- a new
SET
subcommand for the givenbitFieldType
,offset
andvalue
.
-
set
public BitFieldArgs set(int offset, long value)
Adds a newSET
subcommand using the field type of the previous command.- Parameters:
offset
- bitfield offsetvalue
- the value- Returns:
- a new
SET
subcommand for the givenbitFieldType
,offset
andvalue
. - Throws:
IllegalStateException
- if no previous field type was found
-
set
public BitFieldArgs set(BitFieldArgs.BitFieldType bitFieldType, int offset, long value)
Adds a newSET
subcommand.- Parameters:
bitFieldType
- the bit field type, must not benull
.offset
- bitfield offsetvalue
- the value- Returns:
- a new
SET
subcommand for the givenbitFieldType
,offset
andvalue
.
-
set
public BitFieldArgs set(BitFieldArgs.BitFieldType bitFieldType, BitFieldArgs.Offset offset, long value)
Adds a newSET
subcommand.- Parameters:
bitFieldType
- the bit field type, must not benull
.offset
- bitfield offset, must not benull
.value
- the value- Returns:
- a new
SET
subcommand for the givenbitFieldType
,offset
andvalue
. - Since:
- 4.3
-
incrBy
public BitFieldArgs incrBy(long value)
Adds a newINCRBY
subcommand using offset0
and the field type of the previous command.- Parameters:
value
- the value- Returns:
- a new
INCRBY
subcommand for the givenbitFieldType
,offset
andvalue
. - Throws:
IllegalStateException
- if no previous field type was found
-
incrBy
public BitFieldArgs incrBy(BitFieldArgs.BitFieldType bitFieldType, long value)
Adds a newINCRBY
subcommand using offset0
.- Parameters:
bitFieldType
- the bit field type, must not benull
.value
- the value- Returns:
- a new
INCRBY
subcommand for the givenbitFieldType
,offset
andvalue
.
-
incrBy
public BitFieldArgs incrBy(int offset, long value)
Adds a newINCRBY
subcommand using the field type of the previous command.- Parameters:
offset
- bitfield offsetvalue
- the value- Returns:
- a new
INCRBY
subcommand for the givenbitFieldType
,offset
andvalue
. - Throws:
IllegalStateException
- if no previous field type was found
-
incrBy
public BitFieldArgs incrBy(BitFieldArgs.BitFieldType bitFieldType, int offset, long value)
Adds a newINCRBY
subcommand.- Parameters:
bitFieldType
- the bit field type, must not benull
.offset
- bitfield offsetvalue
- the value- Returns:
- a new
INCRBY
subcommand for the givenbitFieldType
,offset
andvalue
.
-
incrBy
public BitFieldArgs incrBy(BitFieldArgs.BitFieldType bitFieldType, BitFieldArgs.Offset offset, long value)
Adds a newINCRBY
subcommand.- Parameters:
bitFieldType
- the bit field type, must not benull
.offset
- bitfield offset, must not benull
.value
- the value- Returns:
- a new
INCRBY
subcommand for the givenbitFieldType
,offset
andvalue
. - Since:
- 4.3
-
overflow
public BitFieldArgs overflow(BitFieldArgs.OverflowType overflowType)
Adds a newOVERFLOW
subcommand.- Parameters:
overflowType
- type of overflow, must not benull
.- Returns:
- a new
OVERFLOW
subcommand for the givenoverflowType
.
-
build
public <K,V> void build(CommandArgs<K,V> args)
Description copied from interface:CompositeArgument
Build command arguments and contribute arguments toCommandArgs
.Implementing classes are required to implement this method. Depending on the command nature and configured arguments, this method may contribute arguments but is not required to add arguments if none are specified.
- Specified by:
build
in interfaceCompositeArgument
- Type Parameters:
K
- Key type.V
- Value type.- Parameters:
args
- the command arguments, must not benull
.
-
-