@Override
    public List<Long> bitField(byte[] key, BitFieldSubCommands subCommands) {
        List<Object> params = new ArrayList<>();
        params.add(key);

        boolean writeOp = false;
        for (BitFieldSubCommands.BitFieldSubCommand subCommand : subCommands) {
            String size = "u";
            if (subCommand.getType().isSigned()) {
                size = "i";
            }
            size += subCommand.getType().getBits();

			String offset = "#";
			if (subCommand.getOffset().isZeroBased()) {
				offset = "";
			}
			offset += subCommand.getOffset().getValue();

			if (subCommand instanceof BitFieldSubCommands.BitFieldGet) {
			    params.add("GET");
			    params.add(size);
			    params.add(offset);
			} else if (subCommand instanceof BitFieldSubCommands.BitFieldSet) {
			    writeOp = true;
			    params.add("SET");
			    params.add(size);
			    params.add(offset);
                params.add(((BitFieldSubCommands.BitFieldSet) subCommand).getValue());
			} else if (subCommand instanceof BitFieldSubCommands.BitFieldIncrBy) {
			    writeOp = true;
			    params.add("INCRBY");
			    params.add(size);
			    params.add(offset);
                params.add(((BitFieldSubCommands.BitFieldIncrBy) subCommand).getValue());

                BitFieldSubCommands.BitFieldIncrBy.Overflow overflow = ((BitFieldSubCommands.BitFieldIncrBy) subCommand).getOverflow();
                if (overflow != null) {
                    params.add("OVERFLOW");
                    params.add(overflow);
                }
			}
		}

        if (writeOp) {
            return write(key, StringCodec.INSTANCE, BITFIELD, params.toArray());
        }
        return read(key, StringCodec.INSTANCE, BITFIELD, params.toArray());
    }
@Test
    public void testBitField() {
        BitFieldSubCommands c = BitFieldSubCommands.create();
        c = c.set(BitFieldSubCommands.BitFieldType.INT_8).valueAt(1).to(120);
        List<Long> list = connection.bitField("testUnsigned".getBytes(), c);
        assertThat(list).containsExactly(0L);

        BitFieldSubCommands c2 = BitFieldSubCommands.create();
        c2 = c2.incr(BitFieldSubCommands.BitFieldType.INT_8).valueAt(1).by(1);
        List<Long> list2 = connection.bitField("testUnsigned".getBytes(), c2);
        assertThat(list2).containsExactly(121L);

        BitFieldSubCommands c3 = BitFieldSubCommands.create();
        c3 = c3.get(BitFieldSubCommands.BitFieldType.INT_8).valueAt(1);
        List<Long> list3 = connection.bitField("testUnsigned".getBytes(), c3);
        assertThat(list3).containsExactly(121L);
    }