Module 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
  • Constructor Details

    • BitFieldArgs

      public BitFieldArgs()
      Creates a new BitFieldArgs instance.
  • Method Details

    • signed

      public static BitFieldArgs.BitFieldType signed​(int bits)
      Creates a new signed BitFieldArgs.BitFieldType for the given number of bits. Redis allows up to 64 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 unsigned BitFieldArgs.BitFieldType for the given number of bits. Redis allows up to 63 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 new BitFieldArgs.Offset for the given offset.
      Parameters:
      offset - zero-based offset.
      Returns:
      the BitFieldArgs.Offset.
      Since:
      4.3
    • typeWidthBasedOffset

      public static BitFieldArgs.Offset typeWidthBasedOffset​(int offset)
      Creates a new BitFieldArgs.Offset for the given offset 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 new GET subcommand using offset 0 and the field type of the previous command.
      Returns:
      a new GET subcommand for the given bitFieldType and offset.
      Throws:
      IllegalStateException - if no previous field type was found
    • get

      public BitFieldArgs get​(BitFieldArgs.BitFieldType bitFieldType)
      Adds a new GET subcommand using offset 0.
      Parameters:
      bitFieldType - the bit field type, must not be null.
      Returns:
      a new GET subcommand for the given bitFieldType and offset.
    • get

      public BitFieldArgs get​(BitFieldArgs.BitFieldType bitFieldType, int offset)
      Adds a new GET subcommand.
      Parameters:
      bitFieldType - the bit field type, must not be null.
      offset - bitfield offset
      Returns:
      a new GET subcommand for the given bitFieldType and offset.
    • get

      public BitFieldArgs get​(BitFieldArgs.BitFieldType bitFieldType, BitFieldArgs.Offset offset)
      Adds a new GET subcommand.
      Parameters:
      bitFieldType - the bit field type, must not be null.
      offset - bitfield offset
      Returns:
      a new GET subcommand for the given bitFieldType and offset.
      Since:
      4.3
    • get

      public BitFieldArgs get​(int offset)
      Adds a new GET subcommand using the field type of the previous command.
      Parameters:
      offset - bitfield offset
      Returns:
      a new GET subcommand for the given bitFieldType and offset.
      Throws:
      IllegalStateException - if no previous field type was found
    • set

      public BitFieldArgs set​(long value)
      Adds a new SET subcommand using offset 0 and the field type of the previous command.
      Parameters:
      value - the value
      Returns:
      a new SET subcommand for the given bitFieldType, offset and value.
      Throws:
      IllegalStateException - if no previous field type was found
    • set

      public BitFieldArgs set​(BitFieldArgs.BitFieldType bitFieldType, long value)
      Adds a new SET subcommand using offset 0.
      Parameters:
      bitFieldType - the bit field type, must not be null.
      value - the value
      Returns:
      a new SET subcommand for the given bitFieldType, offset and value.
    • set

      public BitFieldArgs set​(int offset, long value)
      Adds a new SET subcommand using the field type of the previous command.
      Parameters:
      offset - bitfield offset
      value - the value
      Returns:
      a new SET subcommand for the given bitFieldType, offset and value.
      Throws:
      IllegalStateException - if no previous field type was found
    • set

      public BitFieldArgs set​(BitFieldArgs.BitFieldType bitFieldType, int offset, long value)
      Adds a new SET subcommand.
      Parameters:
      bitFieldType - the bit field type, must not be null.
      offset - bitfield offset
      value - the value
      Returns:
      a new SET subcommand for the given bitFieldType, offset and value.
    • set

      public BitFieldArgs set​(BitFieldArgs.BitFieldType bitFieldType, BitFieldArgs.Offset offset, long value)
      Adds a new SET subcommand.
      Parameters:
      bitFieldType - the bit field type, must not be null.
      offset - bitfield offset, must not be null.
      value - the value
      Returns:
      a new SET subcommand for the given bitFieldType, offset and value.
      Since:
      4.3
    • incrBy

      public BitFieldArgs incrBy​(long value)
      Adds a new INCRBY subcommand using offset 0 and the field type of the previous command.
      Parameters:
      value - the value
      Returns:
      a new INCRBY subcommand for the given bitFieldType, offset and value.
      Throws:
      IllegalStateException - if no previous field type was found
    • incrBy

      public BitFieldArgs incrBy​(BitFieldArgs.BitFieldType bitFieldType, long value)
      Adds a new INCRBY subcommand using offset 0.
      Parameters:
      bitFieldType - the bit field type, must not be null.
      value - the value
      Returns:
      a new INCRBY subcommand for the given bitFieldType, offset and value.
    • incrBy

      public BitFieldArgs incrBy​(int offset, long value)
      Adds a new INCRBY subcommand using the field type of the previous command.
      Parameters:
      offset - bitfield offset
      value - the value
      Returns:
      a new INCRBY subcommand for the given bitFieldType, offset and value.
      Throws:
      IllegalStateException - if no previous field type was found
    • incrBy

      public BitFieldArgs incrBy​(BitFieldArgs.BitFieldType bitFieldType, int offset, long value)
      Adds a new INCRBY subcommand.
      Parameters:
      bitFieldType - the bit field type, must not be null.
      offset - bitfield offset
      value - the value
      Returns:
      a new INCRBY subcommand for the given bitFieldType, offset and value.
    • incrBy

      public BitFieldArgs incrBy​(BitFieldArgs.BitFieldType bitFieldType, BitFieldArgs.Offset offset, long value)
      Adds a new INCRBY subcommand.
      Parameters:
      bitFieldType - the bit field type, must not be null.
      offset - bitfield offset, must not be null.
      value - the value
      Returns:
      a new INCRBY subcommand for the given bitFieldType, offset and value.
      Since:
      4.3
    • overflow

      public BitFieldArgs overflow​(BitFieldArgs.OverflowType overflowType)
      Adds a new OVERFLOW subcommand.
      Parameters:
      overflowType - type of overflow, must not be null.
      Returns:
      a new OVERFLOW subcommand for the given overflowType.
    • build

      public <K,​ V> void build​(CommandArgs<K,​V> args)
      Description copied from interface: CompositeArgument
      Build command arguments and contribute arguments to CommandArgs.

      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 interface CompositeArgument
      Type Parameters:
      K - Key type.
      V - Value type.
      Parameters:
      args - the command arguments, must not be null.