@Override
    public <T> void writeObject(final int fieldNumber, final T value, final Schema<T> schema,
            final boolean repeated) throws IOException
    {
        final WriteSink sink = this.sink;
        final int lastIndent = indent;
        final Schema<?> lastSchema = this.schema;

        if (lastNumber != fieldNumber)
        {
            tail = writeTag(
                    schema.messageName(),
                    repeated,
                    sink,
                    this,
                    writeKey(
                            lastSchema.getFieldName(fieldNumber),
                            lastIndent,
                            false,
                            sink,
                            this,
                            tail));
        }

        if (repeated)
        {
            final int indentRepeated = inc(lastIndent, 2);
            tail = sink.writeByteArray(
                    DASH_AND_SPACE,
                    this,
                    newLine(
                            indentRepeated,
                            sink,
                            this,
                            tail));

            indent = inc(indentRepeated, 2);
        }
        else
            indent = inc(lastIndent, 2);

        // reset (indention kept though)
        this.schema = schema;
        lastNumber = 0;

        schema.writeTo(this, value);

        // restore state
        this.schema = lastSchema;
        lastNumber = fieldNumber;
        indent = lastIndent;
    }
Before serializing a message/object tied to a schema, this should be called.
protostuff-yaml/src/main/java/io/protostuff/YamlOutput.java