Class DescriptorProtos.OneofDescriptorProto.Builder (3.19.4)

publicstaticfinalclass DescriptorProtos.OneofDescriptorProto.BuilderextendsGeneratedMessageV3.Builder<DescriptorProtos.OneofDescriptorProto.Builder>implementsDescriptorProtos.OneofDescriptorProtoOrBuilder

Describes a oneof.

Protobuf type google.protobuf.OneofDescriptorProto

Inherited Members

Static Methods

getDescriptor()

publicstaticfinalDescriptors.DescriptorgetDescriptor()
Returns
Type Description
Descriptors.Descriptor

Methods

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

publicDescriptorProtos.OneofDescriptorProto.BuilderaddRepeatedField(Descriptors.FieldDescriptorfield,Objectvalue)
Parameters
Name Description
field Descriptors.FieldDescriptor
value Object
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

build()

publicDescriptorProtos.OneofDescriptorProtobuild()
Returns
Type Description
DescriptorProtos.OneofDescriptorProto

buildPartial()

publicDescriptorProtos.OneofDescriptorProtobuildPartial()
Returns
Type Description
DescriptorProtos.OneofDescriptorProto

clear()

publicDescriptorProtos.OneofDescriptorProto.Builderclear()

Called by the initialization and clear code paths to allow subclasses to reset any of their builtin fields back to the initial values.

Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

clearField(Descriptors.FieldDescriptor field)

publicDescriptorProtos.OneofDescriptorProto.BuilderclearField(Descriptors.FieldDescriptorfield)
Parameter
Name Description
field Descriptors.FieldDescriptor
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

clearName()

publicDescriptorProtos.OneofDescriptorProto.BuilderclearName()

optional string name = 1;

Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder

This builder for chaining.

clearOneof(Descriptors.OneofDescriptor oneof)

publicDescriptorProtos.OneofDescriptorProto.BuilderclearOneof(Descriptors.OneofDescriptoroneof)

TODO(jieluo): Clear it when all subclasses have implemented this method.

Parameter
Name Description
oneof Descriptors.OneofDescriptor
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

clearOptions()

publicDescriptorProtos.OneofDescriptorProto.BuilderclearOptions()

optional .google.protobuf.OneofOptions options = 2;

Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder

clone()

publicDescriptorProtos.OneofDescriptorProto.Builderclone()

Clones the Builder.

Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

getDefaultInstanceForType()

publicDescriptorProtos.OneofDescriptorProtogetDefaultInstanceForType()

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
Type Description
DescriptorProtos.OneofDescriptorProto

getDescriptorForType()

publicDescriptors.DescriptorgetDescriptorForType()

Get the message's type's descriptor. This differs from the getDescriptor() method of generated message classes in that this method is an abstract method of the Message interface whereas getDescriptor() is a static method of a specific class. They return the same thing.

Returns
Type Description
Descriptors.Descriptor
Overrides

getName()

publicStringgetName()

optional string name = 1;

Returns
Type Description
String

The name.

getNameBytes()

publicByteStringgetNameBytes()

optional string name = 1;

Returns
Type Description
ByteString

The bytes for name.

getOptions()

publicDescriptorProtos.OneofOptionsgetOptions()

optional .google.protobuf.OneofOptions options = 2;

Returns
Type Description
DescriptorProtos.OneofOptions

The options.

getOptionsBuilder()

publicDescriptorProtos.OneofOptions.BuildergetOptionsBuilder()

optional .google.protobuf.OneofOptions options = 2;

Returns
Type Description
DescriptorProtos.OneofOptions.Builder

getOptionsOrBuilder()

publicDescriptorProtos.OneofOptionsOrBuildergetOptionsOrBuilder()

optional .google.protobuf.OneofOptions options = 2;

Returns
Type Description
DescriptorProtos.OneofOptionsOrBuilder

hasName()

publicbooleanhasName()

optional string name = 1;

Returns
Type Description
boolean

Whether the name field is set.

hasOptions()

publicbooleanhasOptions()

optional .google.protobuf.OneofOptions options = 2;

Returns
Type Description
boolean

Whether the options field is set.

internalGetFieldAccessorTable()

protectedGeneratedMessageV3.FieldAccessorTableinternalGetFieldAccessorTable()

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
Type Description
GeneratedMessageV3.FieldAccessorTable
Overrides

isInitialized()

publicfinalbooleanisInitialized()

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

See also: MessageOrBuilder#getInitializationErrorString()

Returns
Type Description
boolean
Overrides

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

publicDescriptorProtos.OneofDescriptorProto.BuildermergeFrom(CodedInputStreaminput,ExtensionRegistryLiteextensionRegistry)

Like Builder#mergeFrom(CodedInputStream), but also parses extensions. The extensions that you want to be able to parse must be registered in extensionRegistry. Extensions not in the registry will be treated as unknown fields.

Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides
Exceptions
Type Description
IOException

mergeFrom(DescriptorProtos.OneofDescriptorProto other)

publicDescriptorProtos.OneofDescriptorProto.BuildermergeFrom(DescriptorProtos.OneofDescriptorProtoother)
Parameter
Name Description
other DescriptorProtos.OneofDescriptorProto
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder

mergeFrom(Message other)

publicDescriptorProtos.OneofDescriptorProto.BuildermergeFrom(Messageother)

Merge other into the message being built. other must have the exact same type as this (i.e. getDescriptorForType() == other.getDescriptorForType()).

Merging occurs as follows. For each field:

  • For singular primitive fields, if the field is set in other, then other's value overwrites the value in this message.
  • For singular message fields, if the field is set in other, it is merged into the corresponding sub-message of this message using the same merging rules.
  • For repeated fields, the elements in other are concatenated with the elements in this message.
  • For oneof groups, if the other message has one of the fields set, the group of this message is cleared and replaced by the field of the other message, so that the oneof constraint is preserved.

    This is equivalent to the Message::MergeFrom method in C++.

Parameter
Name Description
other Message
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

mergeOptions(DescriptorProtos.OneofOptions value)

publicDescriptorProtos.OneofDescriptorProto.BuildermergeOptions(DescriptorProtos.OneofOptionsvalue)

optional .google.protobuf.OneofOptions options = 2;

Parameter
Name Description
value DescriptorProtos.OneofOptions
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder

mergeUnknownFields(UnknownFieldSet unknownFields)

publicfinalDescriptorProtos.OneofDescriptorProto.BuildermergeUnknownFields(UnknownFieldSetunknownFields)

Merge some unknown fields into the UnknownFieldSet for this message.

Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

setField(Descriptors.FieldDescriptor field, Object value)

publicDescriptorProtos.OneofDescriptorProto.BuildersetField(Descriptors.FieldDescriptorfield,Objectvalue)
Parameters
Name Description
field Descriptors.FieldDescriptor
value Object
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

setName(String value)

publicDescriptorProtos.OneofDescriptorProto.BuildersetName(Stringvalue)

optional string name = 1;

Parameter
Name Description
value String

The name to set.

Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder

This builder for chaining.

setNameBytes(ByteString value)

publicDescriptorProtos.OneofDescriptorProto.BuildersetNameBytes(ByteStringvalue)

optional string name = 1;

Parameter
Name Description
value ByteString

The bytes for name to set.

Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder

This builder for chaining.

setOptions(DescriptorProtos.OneofOptions value)

publicDescriptorProtos.OneofDescriptorProto.BuildersetOptions(DescriptorProtos.OneofOptionsvalue)

optional .google.protobuf.OneofOptions options = 2;

Parameter
Name Description
value DescriptorProtos.OneofOptions
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder

setOptions(DescriptorProtos.OneofOptions.Builder builderForValue)

publicDescriptorProtos.OneofDescriptorProto.BuildersetOptions(DescriptorProtos.OneofOptions.BuilderbuilderForValue)

optional .google.protobuf.OneofOptions options = 2;

Parameter
Name Description
builderForValue DescriptorProtos.OneofOptions.Builder
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder

setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)

publicDescriptorProtos.OneofDescriptorProto.BuildersetRepeatedField(Descriptors.FieldDescriptorfield,intindex,Objectvalue)
Parameters
Name Description
field Descriptors.FieldDescriptor
index int
value Object
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

setUnknownFields(UnknownFieldSet unknownFields)

publicfinalDescriptorProtos.OneofDescriptorProto.BuildersetUnknownFields(UnknownFieldSetunknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
DescriptorProtos.OneofDescriptorProto.Builder
Overrides

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月30日 UTC.