Class Descriptors.Descriptor (3.19.4)

public static final class Descriptors.Descriptor extends Descriptors.GenericDescriptor

Describes a message type.

Inheritance

java.lang.Object > Descriptors.GenericDescriptor > Descriptors.Descriptor

Methods

findEnumTypeByName(String name)

public Descriptors.EnumDescriptor findEnumTypeByName(String name)

Finds a nested enum type by name.

Parameter
NameDescription
nameString

The unqualified name of the nested type (e.g. "Foo").

Returns
TypeDescription
Descriptors.EnumDescriptor

The types's descriptor, or null if not found.

findFieldByName(String name)

public Descriptors.FieldDescriptor findFieldByName(String name)

Finds a field by name.

Parameter
NameDescription
nameString

The unqualified name of the field (e.g. "foo"). For protocol buffer messages that follow <a href=https://developers.google.com/protocol-buffers/docs/style#message_and_field_names>Google's guidance on naming this will be a snake case string, such as song_name .

Returns
TypeDescription
Descriptors.FieldDescriptor

The field's descriptor, or null if not found.

findFieldByNumber(int number)

public Descriptors.FieldDescriptor findFieldByNumber(int number)

Finds a field by field number.

Parameter
NameDescription
numberint

The field number within this message type.

Returns
TypeDescription
Descriptors.FieldDescriptor

The field's descriptor, or null if not found.

findNestedTypeByName(String name)

public Descriptors.Descriptor findNestedTypeByName(String name)

Finds a nested message type by name.

Parameter
NameDescription
nameString

The unqualified name of the nested type (e.g. "Foo").

Returns
TypeDescription
Descriptors.Descriptor

The types's descriptor, or null if not found.

getContainingType()

public Descriptors.Descriptor getContainingType()

If this is a nested type, get the outer descriptor, otherwise null.

Returns
TypeDescription
Descriptors.Descriptor

getEnumTypes()

public List<Descriptors.EnumDescriptor> getEnumTypes()

Get a list of enum types nested within this one.

Returns
TypeDescription
List<EnumDescriptor>

getExtensions()

public List<Descriptors.FieldDescriptor> getExtensions()

Get a list of this message type's extensions.

Returns
TypeDescription
List<FieldDescriptor>

getFields()

public List<Descriptors.FieldDescriptor> getFields()

Get a list of this message type's fields.

Returns
TypeDescription
List<FieldDescriptor>

getFile()

public Descriptors.FileDescriptor getFile()

Get the FileDescriptor containing this descriptor.

Returns
TypeDescription
Descriptors.FileDescriptor
Overrides

getFullName()

public String getFullName()

Get the type's fully-qualified name, within the proto language's namespace. This differs from the Java name. For example, given this .proto:

package foo.bar; option java_package = "com.example.protos" message Baz {}

Baz's full name is "foo.bar.Baz".

Returns
TypeDescription
String
Overrides

getIndex()

public int getIndex()

Get the index of this descriptor within its parent. In other words, given a FileDescriptor file, the following is true:

for all i in [0, file.getMessageTypeCount()): file.getMessageType(i).getIndex() == i

Similarly, for a Descriptor messageType:

for all i in [0, messageType.getNestedTypeCount()): messageType.getNestedType(i).getIndex() == i

Returns
TypeDescription
int

getName()

public String getName()

Get the type's unqualified name.

Returns
TypeDescription
String
Overrides

getNestedTypes()

public List<Descriptors.Descriptor> getNestedTypes()

Get a list of message types nested within this one.

Returns
TypeDescription
List<Descriptor>

getOneofs()

public List<Descriptors.OneofDescriptor> getOneofs()

Get a list of this message type's oneofs.

Returns
TypeDescription
List<OneofDescriptor>

getOptions()

public DescriptorProtos.MessageOptions getOptions()

Get the MessageOptions, defined in descriptor.proto.

Returns
TypeDescription
DescriptorProtos.MessageOptions

getRealOneofs()

public List<Descriptors.OneofDescriptor> getRealOneofs()

Get a list of this message type's real oneofs.

Returns
TypeDescription
List<OneofDescriptor>

isExtendable()

public boolean isExtendable()

Indicates whether the message can be extended. That is, whether it has any "extensions x to y" ranges declared on it.

Returns
TypeDescription
boolean

isExtensionNumber(int number)

public boolean isExtensionNumber(int number)

Determines if the given field number is an extension.

Parameter
NameDescription
numberint
Returns
TypeDescription
boolean

isReservedName(String name)

public boolean isReservedName(String name)

Determines if the given field name is reserved.

Parameter
NameDescription
nameString
Returns
TypeDescription
boolean

isReservedNumber(int number)

public boolean isReservedNumber(int number)

Determines if the given field number is reserved.

Parameter
NameDescription
numberint
Returns
TypeDescription
boolean

toProto()

public DescriptorProtos.DescriptorProto toProto()

Convert the descriptor to its protocol message representation.

Returns
TypeDescription
DescriptorProtos.DescriptorProto
Overrides