void resolveReferences(Message root)
    {
        final Proto proto = getProto();
        final String fullName = getFullName();

        for (Field<?> f : fields.values())
        {
            f.owner = this;

            if (f.isRepeated())
            {
                repeatedFieldCount++;
                root.repeatedFieldPresent = true;
            }
            else
            {
                singularFieldCount++;

                if (f.isRequired())
                {
                    requiredFieldCount++;
                    root.requiredFieldPresent = true;
                }
            }

            if (!annotationPresentOnFields && !f.annotations.isEmpty())
                annotationPresentOnFields = true;

            if (f instanceof Field.Bytes)
            {
                if (f.isRepeated())
                    repeatedBytesFieldCount++;
                else
                {
                    singularBytesFieldCount++;

                    if (f.isRequired())
                        requiredBytesFieldCount++;
                }

                if (f.hasOption("ByteBuffer"))
                {
                    root.byteBufferFieldPresent = true;
                }

                if (!root.bytesFieldPresent)
                    root.bytesFieldPresent = true;
                if (!root.bytesOrStringDefaultValuePresent && f.defaultValue != null)
                    root.bytesOrStringDefaultValuePresent = true;
            }
            else if (f instanceof Field.String)
            {
                if (f.isRepeated())
                    repeatedStringFieldCount++;
                else
                {
                    singularStringFieldCount++;

                    if (f.isRequired())
                        requiredStringFieldCount++;
                }

                if (!root.bytesOrStringDefaultValuePresent && f.defaultValue != null)
                    root.bytesOrStringDefaultValuePresent = true;
            }
            else if (f instanceof Field.Reference)
            {
                Field.Reference fr = (Field.Reference) f;
                String refName = fr.refName;
                String packageName = fr.packageName;
                String fullRefName = (packageName == null ? refName : packageName + '.' + refName);

                HasName refObj = proto.findReference(fullRefName, fullName);
                if (refObj instanceof Message)
                {
                    MessageField mf = newMessageField((Message) refObj, fr, this);
                    fields.put(mf.name, mf);

                    if (mf.isRepeated())
                        repeatedMessageFieldCount++;
                    else
                    {
                        singularMessageFieldCount++;

                        if (mf.isRequired())
                            requiredMessageFieldCount++;
                    }

                    // references inside options
                    if (!mf.standardOptions.isEmpty())
                        proto.references.add(new ConfiguredReference(mf.standardOptions, mf.extraOptions, fullName));

                    continue;
                }

                if (refObj instanceof EnumGroup)
                {
                    EnumField ef = newEnumField((EnumGroup) refObj, fr, this);
                    fields.put(ef.name, ef);

                    if (ef.isRepeated())
                        repeatedEnumFieldCount++;
                    else
                    {
                        singularEnumFieldCount++;

                        if (ef.isRequired())
                            requiredEnumFieldCount++;
                    }

                    // references inside options
                    if (!ef.standardOptions.isEmpty())
                        proto.references.add(new ConfiguredReference(ef.standardOptions, ef.extraOptions, fullName));

                    continue;
                }

                throw err("unknown field: " + fullRefName, getProto());
            }

            // references inside options
            if (!f.standardOptions.isEmpty())
                proto.references.add(new ConfiguredReference(f.standardOptions, f.extraOptions, fullName));
        }
        sortedFields.addAll(fields.values());
        Collections.sort(sortedFields);

        for (Extension extension : this.nestedExtensions)
            extension.resolveReferences();

        for (Service s : nestedServices.values())
            s.resolveReferences();

        for (Message m : nestedMessages.values())
            m.resolveReferences(root);
    }
Represents the message defined in the {@link Proto}.

@author David Yu
@created Dec 19, 2009
protostuff-parser/src/main/java/io/protostuff/parser/Message.java