Class DescriptorProtos.FieldDescriptorProto

public static final class DescriptorProtos.FieldDescriptorProto extends GeneratedMessageV3 implements DescriptorProtos.FieldDescriptorProtoOrBuilder

Describes a field within a message.

Protobuf type google.protobuf.FieldDescriptorProto

Inheritance

Object > AbstractMessageLite<MessageType,BuilderType> > AbstractMessage > GeneratedMessageV3 > DescriptorProtos.FieldDescriptorProto

Static Fields

DEFAULT_VALUE_FIELD_NUMBER

public static final int DEFAULT_VALUE_FIELD_NUMBER
Field Value
TypeDescription
int

EXTENDEE_FIELD_NUMBER

public static final int EXTENDEE_FIELD_NUMBER
Field Value
TypeDescription
int

JSON_NAME_FIELD_NUMBER

public static final int JSON_NAME_FIELD_NUMBER
Field Value
TypeDescription
int

LABEL_FIELD_NUMBER

public static final int LABEL_FIELD_NUMBER
Field Value
TypeDescription
int

NAME_FIELD_NUMBER

public static final int NAME_FIELD_NUMBER
Field Value
TypeDescription
int

NUMBER_FIELD_NUMBER

public static final int NUMBER_FIELD_NUMBER
Field Value
TypeDescription
int

ONEOF_INDEX_FIELD_NUMBER

public static final int ONEOF_INDEX_FIELD_NUMBER
Field Value
TypeDescription
int

OPTIONS_FIELD_NUMBER

public static final int OPTIONS_FIELD_NUMBER
Field Value
TypeDescription
int

PARSER

public static final Parser<DescriptorProtos.FieldDescriptorProto> PARSER
Field Value
TypeDescription
Parser<FieldDescriptorProto>

PROTO3_OPTIONAL_FIELD_NUMBER

public static final int PROTO3_OPTIONAL_FIELD_NUMBER
Field Value
TypeDescription
int

TYPE_FIELD_NUMBER

public static final int TYPE_FIELD_NUMBER
Field Value
TypeDescription
int

TYPE_NAME_FIELD_NUMBER

public static final int TYPE_NAME_FIELD_NUMBER
Field Value
TypeDescription
int

Static Methods

getDefaultInstance()

public static DescriptorProtos.FieldDescriptorProto getDefaultInstance()
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
TypeDescription
Descriptors.Descriptor

newBuilder()

public static DescriptorProtos.FieldDescriptorProto.Builder newBuilder()
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto.Builder

newBuilder(DescriptorProtos.FieldDescriptorProto prototype)

public static DescriptorProtos.FieldDescriptorProto.Builder newBuilder(DescriptorProtos.FieldDescriptorProto prototype)
Parameter
NameDescription
prototypeDescriptorProtos.FieldDescriptorProto
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto.Builder

parseDelimitedFrom(InputStream input)

public static DescriptorProtos.FieldDescriptorProto parseDelimitedFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static DescriptorProtos.FieldDescriptorProto parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
IOException

parseFrom(byte[] data)

public static DescriptorProtos.FieldDescriptorProto parseFrom(byte[] data)
Parameter
NameDescription
databyte[]
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static DescriptorProtos.FieldDescriptorProto parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
databyte[]
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data)

public static DescriptorProtos.FieldDescriptorProto parseFrom(ByteString data)
Parameter
NameDescription
dataByteString
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static DescriptorProtos.FieldDescriptorProto parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteString
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static DescriptorProtos.FieldDescriptorProto parseFrom(CodedInputStream input)
Parameter
NameDescription
inputCodedInputStream
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static DescriptorProtos.FieldDescriptorProto parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputCodedInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
IOException

parseFrom(InputStream input)

public static DescriptorProtos.FieldDescriptorProto parseFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static DescriptorProtos.FieldDescriptorProto parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
IOException

parseFrom(ByteBuffer data)

public static DescriptorProtos.FieldDescriptorProto parseFrom(ByteBuffer data)
Parameter
NameDescription
dataByteBuffer
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static DescriptorProtos.FieldDescriptorProto parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteBuffer
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto
Exceptions
TypeDescription
InvalidProtocolBufferException

parser()

public static Parser<DescriptorProtos.FieldDescriptorProto> parser()
Returns
TypeDescription
Parser<FieldDescriptorProto>

Methods

equals(Object obj)

public boolean equals(Object obj)

Compares the specified object with this message for equality. Returns true if the given object is a message of the same type (as defined by getDescriptorForType()) and has identical values for all of its fields. Subclasses must implement this; inheriting Object.equals() is incorrect.

Parameter
NameDescription
objObject
Returns
TypeDescription
boolean
Overrides

getDefaultInstanceForType()

public DescriptorProtos.FieldDescriptorProto getDefaultInstanceForType()

Get an instance of the type with no fields set. Because no fields are set, all getters for singular fields will return default values and repeated fields will appear empty. This may or may not be a singleton. This differs from the getDefaultInstance() method of generated message classes in that this method is an abstract method of the MessageLite interface whereas getDefaultInstance() is a static method of a specific class. They return the same thing.

Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto

getDefaultValue()

public String getDefaultValue()

For numeric types, contains the original text representation of the value. For booleans, "true" or "false". For strings, contains the default text contents (not escaped in any way). For bytes, contains the C escaped value. All bytes >= 128 are escaped. TODO(kenton): Base-64 encode?

optional string default_value = 7;

Returns
TypeDescription
String

The defaultValue.

getDefaultValueBytes()

public ByteString getDefaultValueBytes()

For numeric types, contains the original text representation of the value. For booleans, "true" or "false". For strings, contains the default text contents (not escaped in any way). For bytes, contains the C escaped value. All bytes >= 128 are escaped. TODO(kenton): Base-64 encode?

optional string default_value = 7;

Returns
TypeDescription
ByteString

The bytes for defaultValue.

getExtendee()

public String getExtendee()

For extensions, this is the name of the type being extended. It is resolved in the same manner as type_name.

optional string extendee = 2;

Returns
TypeDescription
String

The extendee.

getExtendeeBytes()

public ByteString getExtendeeBytes()

For extensions, this is the name of the type being extended. It is resolved in the same manner as type_name.

optional string extendee = 2;

Returns
TypeDescription
ByteString

The bytes for extendee.

getJsonName()

public String getJsonName()

JSON name of this field. The value is set by protocol compiler. If the user has set a "json_name" option on this field, that option's value will be used. Otherwise, it's deduced from the field's name by converting it to camelCase.

optional string json_name = 10;

Returns
TypeDescription
String

The jsonName.

getJsonNameBytes()

public ByteString getJsonNameBytes()

JSON name of this field. The value is set by protocol compiler. If the user has set a "json_name" option on this field, that option's value will be used. Otherwise, it's deduced from the field's name by converting it to camelCase.

optional string json_name = 10;

Returns
TypeDescription
ByteString

The bytes for jsonName.

getLabel()

public DescriptorProtos.FieldDescriptorProto.Label getLabel()

optional .google.protobuf.FieldDescriptorProto.Label label = 4;

Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto.Label

The label.

getName()

public String getName()

optional string name = 1;

Returns
TypeDescription
String

The name.

getNameBytes()

public ByteString getNameBytes()

optional string name = 1;

Returns
TypeDescription
ByteString

The bytes for name.

getNumber()

public int getNumber()

optional int32 number = 3;

Returns
TypeDescription
int

The number.

getOneofIndex()

public int getOneofIndex()

If set, gives the index of a oneof in the containing type's oneof_decl list. This field is a member of that oneof.

optional int32 oneof_index = 9;

Returns
TypeDescription
int

The oneofIndex.

getOptions()

public DescriptorProtos.FieldOptions getOptions()

optional .google.protobuf.FieldOptions options = 8;

Returns
TypeDescription
DescriptorProtos.FieldOptions

The options.

getOptionsOrBuilder()

public DescriptorProtos.FieldOptionsOrBuilder getOptionsOrBuilder()

optional .google.protobuf.FieldOptions options = 8;

Returns
TypeDescription
DescriptorProtos.FieldOptionsOrBuilder

getParserForType()

public Parser<DescriptorProtos.FieldDescriptorProto> getParserForType()
Returns
TypeDescription
Parser<FieldDescriptorProto>
Overrides

getProto3Optional()

public boolean getProto3Optional()

If true, this is a proto3 "optional". When a proto3 field is optional, it tracks presence regardless of field type. When proto3_optional is true, this field must be belong to a oneof to signal to old proto3 clients that presence is tracked for this field. This oneof is known as a "synthetic" oneof, and this field must be its sole member (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs exist in the descriptor only, and do not generate any API. Synthetic oneofs must be ordered after all "real" oneofs. For message fields, proto3_optional doesn't create any semantic change, since non-repeated message fields always track presence. However it still indicates the semantic detail of whether the user wrote "optional" or not. This can be useful for round-tripping the .proto file. For consistency we give message fields a synthetic oneof also, even though it is not required to track presence. This is especially important because the parser can't tell if a field is a message or an enum, so it must always create a synthetic oneof. Proto2 optional fields do not set this flag, because they already indicate optional with LABEL_OPTIONAL.

optional bool proto3_optional = 17;

Returns
TypeDescription
boolean

The proto3Optional.

getSerializedSize()

public int getSerializedSize()

Get the number of bytes required to encode this message. The result is only computed on the first call and memoized after that.

If this message requires more than Integer.MAX_VALUE bytes to encode, the return value will be smaller than the actual number of bytes required and might be negative.

Returns
TypeDescription
int
Overrides

getType()

public DescriptorProtos.FieldDescriptorProto.Type getType()

If type_name is set, this need not be set. If both this and type_name are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.

optional .google.protobuf.FieldDescriptorProto.Type type = 5;

Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto.Type

The type.

getTypeName()

public String getTypeName()

For message and enum types, this is the name of the type. If the name starts with a '.', it is fully-qualified. Otherwise, C++-like scoping rules are used to find the type (i.e. first the nested types within this message are searched, then within the parent, on up to the root namespace).

optional string type_name = 6;

Returns
TypeDescription
String

The typeName.

getTypeNameBytes()

public ByteString getTypeNameBytes()

For message and enum types, this is the name of the type. If the name starts with a '.', it is fully-qualified. Otherwise, C++-like scoping rules are used to find the type (i.e. first the nested types within this message are searched, then within the parent, on up to the root namespace).

optional string type_name = 6;

Returns
TypeDescription
ByteString

The bytes for typeName.

getUnknownFields()

public final UnknownFieldSet getUnknownFields()

Get the UnknownFieldSet for this message.

Returns
TypeDescription
UnknownFieldSet
Overrides

hasDefaultValue()

public boolean hasDefaultValue()

For numeric types, contains the original text representation of the value. For booleans, "true" or "false". For strings, contains the default text contents (not escaped in any way). For bytes, contains the C escaped value. All bytes >= 128 are escaped. TODO(kenton): Base-64 encode?

optional string default_value = 7;

Returns
TypeDescription
boolean

Whether the defaultValue field is set.

hasExtendee()

public boolean hasExtendee()

For extensions, this is the name of the type being extended. It is resolved in the same manner as type_name.

optional string extendee = 2;

Returns
TypeDescription
boolean

Whether the extendee field is set.

hasJsonName()

public boolean hasJsonName()

JSON name of this field. The value is set by protocol compiler. If the user has set a "json_name" option on this field, that option's value will be used. Otherwise, it's deduced from the field's name by converting it to camelCase.

optional string json_name = 10;

Returns
TypeDescription
boolean

Whether the jsonName field is set.

hasLabel()

public boolean hasLabel()

optional .google.protobuf.FieldDescriptorProto.Label label = 4;

Returns
TypeDescription
boolean

Whether the label field is set.

hasName()

public boolean hasName()

optional string name = 1;

Returns
TypeDescription
boolean

Whether the name field is set.

hasNumber()

public boolean hasNumber()

optional int32 number = 3;

Returns
TypeDescription
boolean

Whether the number field is set.

hasOneofIndex()

public boolean hasOneofIndex()

If set, gives the index of a oneof in the containing type's oneof_decl list. This field is a member of that oneof.

optional int32 oneof_index = 9;

Returns
TypeDescription
boolean

Whether the oneofIndex field is set.

hasOptions()

public boolean hasOptions()

optional .google.protobuf.FieldOptions options = 8;

Returns
TypeDescription
boolean

Whether the options field is set.

hasProto3Optional()

public boolean hasProto3Optional()

If true, this is a proto3 "optional". When a proto3 field is optional, it tracks presence regardless of field type. When proto3_optional is true, this field must be belong to a oneof to signal to old proto3 clients that presence is tracked for this field. This oneof is known as a "synthetic" oneof, and this field must be its sole member (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs exist in the descriptor only, and do not generate any API. Synthetic oneofs must be ordered after all "real" oneofs. For message fields, proto3_optional doesn't create any semantic change, since non-repeated message fields always track presence. However it still indicates the semantic detail of whether the user wrote "optional" or not. This can be useful for round-tripping the .proto file. For consistency we give message fields a synthetic oneof also, even though it is not required to track presence. This is especially important because the parser can't tell if a field is a message or an enum, so it must always create a synthetic oneof. Proto2 optional fields do not set this flag, because they already indicate optional with LABEL_OPTIONAL.

optional bool proto3_optional = 17;

Returns
TypeDescription
boolean

Whether the proto3Optional field is set.

hasType()

public boolean hasType()

If type_name is set, this need not be set. If both this and type_name are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.

optional .google.protobuf.FieldDescriptorProto.Type type = 5;

Returns
TypeDescription
boolean

Whether the type field is set.

hasTypeName()

public boolean hasTypeName()

For message and enum types, this is the name of the type. If the name starts with a '.', it is fully-qualified. Otherwise, C++-like scoping rules are used to find the type (i.e. first the nested types within this message are searched, then within the parent, on up to the root namespace).

optional string type_name = 6;

Returns
TypeDescription
boolean

Whether the typeName field is set.

hashCode()

public int hashCode()

Returns the hash code value for this message. The hash code of a message should mix the message's type (object identity of the descriptor) with its contents (known and unknown field values). Subclasses must implement this; inheriting Object.hashCode() is incorrect.

Returns
TypeDescription
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()

Get the FieldAccessorTable for this type. We can't have the message class pass this in to the constructor because of bootstrapping trouble with DescriptorProtos.

Returns
TypeDescription
GeneratedMessageV3.FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()

Returns true if all required fields in the message and all embedded messages are set, false otherwise.

See also: MessageOrBuilder#getInitializationErrorString()

Returns
TypeDescription
boolean
Overrides

newBuilderForType()

public DescriptorProtos.FieldDescriptorProto.Builder newBuilderForType()
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected DescriptorProtos.FieldDescriptorProto.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)

TODO(xiaofeng): remove this together with GeneratedMessageV3.BuilderParent.

Parameter
NameDescription
parentGeneratedMessageV3.BuilderParent
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

Creates a new instance of this message type. Overridden in the generated code.

Parameter
NameDescription
unusedGeneratedMessageV3.UnusedPrivateParameter
Returns
TypeDescription
Object
Overrides

toBuilder()

public DescriptorProtos.FieldDescriptorProto.Builder toBuilder()
Returns
TypeDescription
DescriptorProtos.FieldDescriptorProto.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)

Serializes the message and writes it to output. This does not flush or close the stream.

Parameter
NameDescription
outputCodedOutputStream
Overrides Exceptions
TypeDescription
IOException