'Generates flattened RDFValue class definition for the given value.'

def MakeFlatRDFClass(self, value):

    def Flatten(self, metadata, value_to_flatten):
        if metadata:
            self.metadata = metadata
        for desc in value_to_flatten.type_infos:
            if (desc.name == 'metadata'):
                continue
            if (hasattr(self, desc.name) and value_to_flatten.HasField(desc.name)):
                setattr(self, desc.name, getattr(value_to_flatten, desc.name))
    output_class = type(self.ExportedClassNameForValue(value), (AutoExportedProtoStruct,), dict(Flatten=Flatten))
    output_class.AddDescriptor(rdf_structs.ProtoEmbedded(name='metadata', field_number=1, nested=ExportedMetadata))
    for (number, desc) in sorted(value.type_infos_by_field_number.items()):
        if (desc.name == 'metadata'):
            logging.debug("Ignoring    'metadata'    field    in    %s.", value.__class__.__name__)
            continue
        if isinstance(desc, (rdf_structs.ProtoBinary, rdf_structs.ProtoString, rdf_structs.ProtoUnsignedInteger, rdf_structs.ProtoRDFValue, rdf_structs.ProtoEnum)):
            output_class.AddDescriptor(desc.Copy(field_number=(number + 1)))
        if (isinstance(desc, rdf_structs.ProtoEnum) and (not isinstance(desc, rdf_structs.ProtoBoolean))):
            setattr(output_class, desc.enum_name, desc.enum_container)
    return output_class
