class PubSubOutput<K, V> extends CommandOutput<K, V, V> implements PubSubMessage<K, V> {

    public enum Type {

        message, pmessage, psubscribe, punsubscribe, subscribe, unsubscribe, ssubscribe;

        private final static Set<String> names = new HashSet<>();

        static {
            for (Type value : Type.values()) {
                names.add(value.name());
            }
        }

        public static boolean isPubSubType(String name) {
            return names.contains(name);
        }

    }

    private Type type;

    private K channel;

    private K pattern;

    private long count;

    private boolean completed;

    public PubSubOutput(RedisCodec<K, V> codec) {
        super(codec, null);
    }

    public Type type() {
        return type;
    }

    public K channel() {
        return channel;
    }

    public K pattern() {
        return pattern;
    }

    public long count() {
        return count;
    }

    @Override
    @SuppressWarnings({ "fallthrough", "unchecked" })
    public void set(ByteBuffer bytes) {

        if (bytes == null) {
            return;
        }

        if (type == null) {
            type = Type.valueOf(decodeAscii(bytes));
            return;
        }

        handleOutput(bytes);
    }

    @SuppressWarnings("unchecked")
    private void handleOutput(ByteBuffer bytes) {<FILL_FUNCTION_BODY>}

    @Override
    public void set(long integer) {
        count = integer;
        // count comes last in (p)(un)subscribe ack.
        completed = true;
    }

    boolean isCompleted() {
        return completed;
    }

    @Override
    public V body() {
        return output;
    }

}

        switch (type) {
            case pmessage:
                if (pattern == null) {
                    pattern = codec.decodeKey(bytes);
                    break;
                }
            case message:
                if (channel == null) {
                    channel = codec.decodeKey(bytes);
                    break;
                }
                output = codec.decodeValue(bytes);
                completed = true;
                break;
            case psubscribe:
            case punsubscribe:
                pattern = codec.decodeKey(bytes);
                break;
            case subscribe:
            case unsubscribe:
            case ssubscribe:
                channel = codec.decodeKey(bytes);
                break;
            default:
                throw new UnsupportedOperationException("Operation " + type + " not supported");
        }
    
<methods>public void <init>(RedisCodec<K,V>, V) ,public void complete(int) ,public V 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 V output