class GenericValueMessage implements ValueMessage {
    /** */
    @GridDirectTransient
    private Object val;

    /** */
    private byte[] serialized;

    /** */
    public GenericValueMessage() {

    }

    /** */
    public GenericValueMessage(Object val) {
        this.val = val;
    }

    /** {@inheritDoc} */
    @Override public Object value() {
        return val;
    }

    /** {@inheritDoc} */
    @Override public void prepareMarshal(MarshallingContext ctx) throws IgniteCheckedException {
        if (val != null && serialized == null)
            serialized = ctx.marshal(val);
    }

    /** {@inheritDoc} */
    @Override public void prepareUnmarshal(MarshallingContext ctx) throws IgniteCheckedException {
        if (serialized != null && val == null)
            val = ctx.unmarshal(serialized);
    }

    /** {@inheritDoc} */
    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
        reader.setBuffer(buf);

        if (!reader.beforeMessageRead())
            return false;

        switch (reader.state()) {
            case 0:
                serialized = reader.readByteArray("serialized");

                if (!reader.isLastRead())
                    return false;

                reader.incrementState();

        }

        return reader.afterMessageRead(GenericValueMessage.class);
    }

    /** {@inheritDoc} */
    @Override public MessageType type() {
        return MessageType.GENERIC_VALUE_MESSAGE;
    }

    /** {@inheritDoc} */
    @Override public byte fieldsCount() {
        return 1;
    }
}

        writer.setBuffer(buf);

        if (!writer.isHeaderWritten()) {
            if (!writer.writeHeader(directType(), fieldsCount()))
                return false;

            writer.onHeaderWritten();
        }

        switch (writer.state()) {
            case 0:
                if (!writer.writeByteArray("serialized", serialized))
                    return false;

                writer.incrementState();

        }

        return true;
    
<no_super_class>