class ObjectOutput<K, V> extends CommandOutput<K, V, Object> {

    private final Deque<Object> stack;

    private Object current;

    private boolean hasCurrent = false;

    private int depth;

    private boolean initialized;

    public ObjectOutput(RedisCodec<K, V> codec) {
        super(codec, Collections.emptyList());
        stack = LettuceFactories.newSpScQueue();
        depth = 0;
    }

    @Override
    public void set(long integer) {

        if (!initialized) {
            output = new ArrayList<>();
        }

        setValue(integer);
    }

    @Override
    public void set(double number) {
        setValue(number);
    }

    @Override
    public void setBigNumber(ByteBuffer bytes) {
        setSingle(bytes);
    }

    @Override
    public void set(boolean value) {
        setValue(value);
    }

    @Override
    public void set(ByteBuffer bytes) {
        setValue(bytes == null ? null : codec.decodeValue(bytes));
    }

    @Override
    public void setSingle(ByteBuffer bytes) {
        setValue(bytes == null ? null : StringCodec.UTF8.decodeValue(bytes));
    }

    @SuppressWarnings("unchecked")
    private void setValue(Object value) {

        if (output != null) {

            if (output instanceof Collection) {
                ((Collection<Object>) output).add(value);
            } else if (output instanceof Map) {
                if (!hasCurrent) {
                    current = value;
                    hasCurrent = true;
                } else {
                    ((Map<Object, Object>) output).put(current, value);
                    current = null;
                    hasCurrent = false;
                }
            } else {
                throw new IllegalStateException(
                        String.format("Output %s is not a supported container type to append a response value", output));
            }
        } else {
            output = value;
        }
    }

    @Override
    public void complete(int depth) {
        if (depth > 0 && depth < this.depth) {
            stack.pop();
            output = stack.peek();
            this.depth--;
        }
    }

    @Override
    public void multi(int count) {

        if (!initialized) {
            output = OutputFactory.newList(Math.max(1, count));
            push(output);
            initialized = true;
        } else {
            List<Object> list = OutputFactory.newList(count);
            setValue(list);
            push(list);
            output = list;
        }

        this.depth++;
    }

    @Override
    public void multiMap(int count) {<FILL_FUNCTION_BODY>}

    private void push(Object output) {
        stack.push(output);
    }

}


        if (!initialized) {
            output = new LinkedHashMap<>(count);
            initialized = true;
            push(output);
        } else {

            Map<Object, Object> map = new LinkedHashMap<>(count);
            setValue(map);
            push(map);
            output = map;
        }

        this.depth++;
    
<methods>public void <init>(RedisCodec<K,V>, java.lang.Object) ,public void complete(int) ,public java.lang.Object get() ,public java.lang.String getError() ,public boolean hasError() ,public void multi(int) ,public void multiArray(int) ,public void multiMap(int) ,public void multiPush(int) ,public void multiSet(int) ,public void set(java.nio.ByteBuffer) ,public void set(long) ,public void set(double) ,public void set(boolean) ,public void setBigNumber(java.nio.ByteBuffer) ,public void setError(java.nio.ByteBuffer) ,public void setError(java.lang.String) ,public void setSingle(java.nio.ByteBuffer) ,public java.lang.String toString() <variables>protected final non-sealed RedisCodec<K,V> codec,protected java.lang.String error,protected java.lang.Object output