Package com.google.protobuf
Class Field.Builder
- All Implemented Interfaces:
FieldOrBuilder
,Message.Builder
,MessageLite.Builder
,MessageLiteOrBuilder
,MessageOrBuilder
,Cloneable
- Enclosing class:
Field
public static final class Field.Builder
extends GeneratedMessageV3.Builder<Field.Builder>
implements FieldOrBuilder
A single field of a message type.Protobuf type
google.protobuf.Field
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite.Builder
AbstractMessageLite.Builder.LimitedInputStream
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAllOptions
(Iterable<? extends Option> values) The protocol buffer options.addOptions
(int index, Option value) The protocol buffer options.addOptions
(int index, Option.Builder builderForValue) The protocol buffer options.addOptions
(Option value) The protocol buffer options.addOptions
(Option.Builder builderForValue) The protocol buffer options.The protocol buffer options.addOptionsBuilder
(int index) The protocol buffer options.addRepeatedField
(Descriptors.FieldDescriptor field, Object value) LikesetRepeatedField
, but appends the value as a new element.build()
Constructs the message based on the state of the Builder.LikeMessageLite.Builder.build()
, but does not throw an exception if the message is missing required fields.clear()
Called by the initialization and clear code paths to allow subclasses to reset any of their builtin fields back to the initial values.The field cardinality.The string value of the default value of this field.Clears the field.The field JSON name.The field type.The field name.The field number.TODO(jieluo): Clear it when all subclasses have implemented this method.The index of the field type in `Type.oneofs`, for message or enumeration types.The protocol buffer options.Whether to use alternative packed wire representation.The field type URL, without the scheme, for message or enumeration types.clone()
Clones the Builder.private void
The field cardinality.int
The field cardinality.Get an instance of the type with no fields set.The string value of the default value of this field.The string value of the default value of this field.static final Descriptors.Descriptor
Get the message's type's descriptor.The field JSON name.The field JSON name.getKind()
The field type.int
The field type.getName()
The field name.The field name.int
The field number.int
The index of the field type in `Type.oneofs`, for message or enumeration types.getOptions
(int index) The protocol buffer options.getOptionsBuilder
(int index) The protocol buffer options.The protocol buffer options.int
The protocol buffer options.The protocol buffer options.getOptionsOrBuilder
(int index) The protocol buffer options.List
<? extends OptionOrBuilder> The protocol buffer options.boolean
Whether to use alternative packed wire representation.The field type URL, without the scheme, for message or enumeration types.The field type URL, without the scheme, for message or enumeration types.protected GeneratedMessageV3.FieldAccessorTable
Get the FieldAccessorTable for this type.final boolean
Returns true if all required fields in the message and all embedded messages are set, false otherwise.mergeFrom
(CodedInputStream input, ExtensionRegistryLite extensionRegistry) LikeMessageLite.Builder.mergeFrom(CodedInputStream)
, but also parses extensions.Mergeother
into the message being built.final Field.Builder
mergeUnknownFields
(UnknownFieldSet unknownFields) Merge some unknown fields into theUnknownFieldSet
for this message.removeOptions
(int index) The protocol buffer options.setCardinality
(Field.Cardinality value) The field cardinality.setCardinalityValue
(int value) The field cardinality.setDefaultValue
(String value) The string value of the default value of this field.setDefaultValueBytes
(ByteString value) The string value of the default value of this field.setField
(Descriptors.FieldDescriptor field, Object value) Sets a field to the given value.setJsonName
(String value) The field JSON name.setJsonNameBytes
(ByteString value) The field JSON name.setKind
(Field.Kind value) The field type.setKindValue
(int value) The field type.The field name.setNameBytes
(ByteString value) The field name.setNumber
(int value) The field number.setOneofIndex
(int value) The index of the field type in `Type.oneofs`, for message or enumeration types.setOptions
(int index, Option value) The protocol buffer options.setOptions
(int index, Option.Builder builderForValue) The protocol buffer options.setPacked
(boolean value) Whether to use alternative packed wire representation.setRepeatedField
(Descriptors.FieldDescriptor field, int index, Object value) Sets an element of a repeated field to the given value.setTypeUrl
(String value) The field type URL, without the scheme, for message or enumeration types.setTypeUrlBytes
(ByteString value) The field type URL, without the scheme, for message or enumeration types.final Field.Builder
setUnknownFields
(UnknownFieldSet unknownFields) Set theUnknownFieldSet
for this message.Methods inherited from class com.google.protobuf.GeneratedMessageV3.Builder
dispose, getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getParentForChildren, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, getUnknownFieldSetBuilder, hasField, hasOneof, internalGetMapField, internalGetMutableMapField, isClean, markClean, mergeUnknownLengthDelimitedField, mergeUnknownVarintField, newBuilderForField, onBuilt, onChanged, parseUnknownField, setUnknownFieldSetBuilder, setUnknownFieldsProto3
Methods inherited from class com.google.protobuf.AbstractMessage.Builder
findInitializationErrors, getInitializationErrorString, internalMergeFrom, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toString
Methods inherited from class com.google.protobuf.AbstractMessageLite.Builder
addAll, addAll, mergeFrom, newUninitializedMessageException
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.protobuf.MessageLite.Builder
mergeFrom
Methods inherited from interface com.google.protobuf.MessageOrBuilder
findInitializationErrors, getAllFields, getField, getInitializationErrorString, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof
-
Field Details
-
bitField0_
private int bitField0_ -
kind_
private int kind_ -
cardinality_
private int cardinality_ -
number_
private int number_ -
name_
-
typeUrl_
-
oneofIndex_
private int oneofIndex_ -
packed_
private boolean packed_ -
options_
-
optionsBuilder_
-
jsonName_
-
defaultValue_
-
-
Constructor Details
-
Builder
private Builder() -
Builder
-
-
Method Details
-
getDescriptor
-
internalGetFieldAccessorTable
Description copied from class:GeneratedMessageV3.Builder
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.- Specified by:
internalGetFieldAccessorTable
in classGeneratedMessageV3.Builder<Field.Builder>
-
clear
Description copied from class:GeneratedMessageV3.Builder
Called by the initialization and clear code paths to allow subclasses to reset any of their builtin fields back to the initial values.- Specified by:
clear
in interfaceMessage.Builder
- Specified by:
clear
in interfaceMessageLite.Builder
- Overrides:
clear
in classGeneratedMessageV3.Builder<Field.Builder>
-
getDescriptorForType
Description copied from interface:Message.Builder
Get the message's type's descriptor. SeeMessageOrBuilder.getDescriptorForType()
.- Specified by:
getDescriptorForType
in interfaceMessage.Builder
- Specified by:
getDescriptorForType
in interfaceMessageOrBuilder
- Overrides:
getDescriptorForType
in classGeneratedMessageV3.Builder<Field.Builder>
-
getDefaultInstanceForType
Description copied from interface:MessageLiteOrBuilder
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 thegetDefaultInstance()
method of generated message classes in that this method is an abstract method of theMessageLite
interface whereasgetDefaultInstance()
is a static method of a specific class. They return the same thing.- Specified by:
getDefaultInstanceForType
in interfaceMessageLiteOrBuilder
- Specified by:
getDefaultInstanceForType
in interfaceMessageOrBuilder
-
build
Description copied from interface:MessageLite.Builder
Constructs the message based on the state of the Builder. Subsequent changes to the Builder will not affect the returned message.- Specified by:
build
in interfaceMessage.Builder
- Specified by:
build
in interfaceMessageLite.Builder
-
buildPartial
Description copied from interface:MessageLite.Builder
LikeMessageLite.Builder.build()
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned. Subsequent changes to the Builder will not affect the returned message.- Specified by:
buildPartial
in interfaceMessage.Builder
- Specified by:
buildPartial
in interfaceMessageLite.Builder
-
clone
Description copied from interface:MessageLite.Builder
Clones the Builder.- Specified by:
clone
in interfaceMessage.Builder
- Specified by:
clone
in interfaceMessageLite.Builder
- Overrides:
clone
in classGeneratedMessageV3.Builder<Field.Builder>
- See Also:
-
setField
Description copied from interface:Message.Builder
Sets a field to the given value. The value must be of the correct type for this field, i.e. the same type thatMessageOrBuilder.getField(Descriptors.FieldDescriptor)
would return.- Specified by:
setField
in interfaceMessage.Builder
- Overrides:
setField
in classGeneratedMessageV3.Builder<Field.Builder>
-
clearField
Description copied from interface:Message.Builder
Clears the field. This is exactly equivalent to calling the generated "clear" accessor method corresponding to the field.- Specified by:
clearField
in interfaceMessage.Builder
- Overrides:
clearField
in classGeneratedMessageV3.Builder<Field.Builder>
-
clearOneof
Description copied from class:AbstractMessage.Builder
TODO(jieluo): Clear it when all subclasses have implemented this method.- Specified by:
clearOneof
in interfaceMessage.Builder
- Overrides:
clearOneof
in classGeneratedMessageV3.Builder<Field.Builder>
-
setRepeatedField
Description copied from interface:Message.Builder
Sets an element of a repeated field to the given value. The value must be of the correct type for this field, i.e. the same type thatMessageOrBuilder.getRepeatedField(Descriptors.FieldDescriptor,int)
would return.- Specified by:
setRepeatedField
in interfaceMessage.Builder
- Overrides:
setRepeatedField
in classGeneratedMessageV3.Builder<Field.Builder>
-
addRepeatedField
Description copied from interface:Message.Builder
LikesetRepeatedField
, but appends the value as a new element.- Specified by:
addRepeatedField
in interfaceMessage.Builder
- Overrides:
addRepeatedField
in classGeneratedMessageV3.Builder<Field.Builder>
-
mergeFrom
Description copied from interface:Message.Builder
Mergeother
into the message being built.other
must have the exact same type asthis
(i.e.getDescriptorForType() == other.getDescriptorForType()
).Merging occurs as follows. For each field:
* For singular primitive fields, if the field is set inother
, thenother
's value overwrites the value in this message.
* For singular message fields, if the field is set inother
, it is merged into the corresponding sub-message of this message using the same merging rules.
* For repeated fields, the elements inother
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++.- Specified by:
mergeFrom
in interfaceMessage.Builder
- Overrides:
mergeFrom
in classAbstractMessage.Builder<Field.Builder>
-
mergeFrom
-
isInitialized
public final boolean isInitialized()Description copied from interface:MessageLiteOrBuilder
Returns true if all required fields in the message and all embedded messages are set, false otherwise.- Specified by:
isInitialized
in interfaceMessageLiteOrBuilder
- Overrides:
isInitialized
in classGeneratedMessageV3.Builder<Field.Builder>
-
mergeFrom
public Field.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:MessageLite.Builder
LikeMessageLite.Builder.mergeFrom(CodedInputStream)
, but also parses extensions. The extensions that you want to be able to parse must be registered inextensionRegistry
. Extensions not in the registry will be treated as unknown fields.- Specified by:
mergeFrom
in interfaceMessage.Builder
- Specified by:
mergeFrom
in interfaceMessageLite.Builder
- Overrides:
mergeFrom
in classAbstractMessage.Builder<Field.Builder>
- Throws:
IOException
-
getKindValue
public int getKindValue()The field type.
.google.protobuf.Field.Kind kind = 1;
- Specified by:
getKindValue
in interfaceFieldOrBuilder
- Returns:
- The enum numeric value on the wire for kind.
-
setKindValue
The field type.
.google.protobuf.Field.Kind kind = 1;
- Parameters:
value
- The enum numeric value on the wire for kind to set.- Returns:
- This builder for chaining.
-
getKind
The field type.
.google.protobuf.Field.Kind kind = 1;
- Specified by:
getKind
in interfaceFieldOrBuilder
- Returns:
- The kind.
-
setKind
The field type.
.google.protobuf.Field.Kind kind = 1;
- Parameters:
value
- The kind to set.- Returns:
- This builder for chaining.
-
clearKind
The field type.
.google.protobuf.Field.Kind kind = 1;
- Returns:
- This builder for chaining.
-
getCardinalityValue
public int getCardinalityValue()The field cardinality.
.google.protobuf.Field.Cardinality cardinality = 2;
- Specified by:
getCardinalityValue
in interfaceFieldOrBuilder
- Returns:
- The enum numeric value on the wire for cardinality.
-
setCardinalityValue
The field cardinality.
.google.protobuf.Field.Cardinality cardinality = 2;
- Parameters:
value
- The enum numeric value on the wire for cardinality to set.- Returns:
- This builder for chaining.
-
getCardinality
The field cardinality.
.google.protobuf.Field.Cardinality cardinality = 2;
- Specified by:
getCardinality
in interfaceFieldOrBuilder
- Returns:
- The cardinality.
-
setCardinality
The field cardinality.
.google.protobuf.Field.Cardinality cardinality = 2;
- Parameters:
value
- The cardinality to set.- Returns:
- This builder for chaining.
-
clearCardinality
The field cardinality.
.google.protobuf.Field.Cardinality cardinality = 2;
- Returns:
- This builder for chaining.
-
getNumber
public int getNumber()The field number.
int32 number = 3;
- Specified by:
getNumber
in interfaceFieldOrBuilder
- Returns:
- The number.
-
setNumber
The field number.
int32 number = 3;
- Parameters:
value
- The number to set.- Returns:
- This builder for chaining.
-
clearNumber
The field number.
int32 number = 3;
- Returns:
- This builder for chaining.
-
getName
The field name.
string name = 4;
- Specified by:
getName
in interfaceFieldOrBuilder
- Returns:
- The name.
-
getNameBytes
The field name.
string name = 4;
- Specified by:
getNameBytes
in interfaceFieldOrBuilder
- Returns:
- The bytes for name.
-
setName
The field name.
string name = 4;
- Parameters:
value
- The name to set.- Returns:
- This builder for chaining.
-
clearName
The field name.
string name = 4;
- Returns:
- This builder for chaining.
-
setNameBytes
The field name.
string name = 4;
- Parameters:
value
- The bytes for name to set.- Returns:
- This builder for chaining.
-
getTypeUrl
The field type URL, without the scheme, for message or enumeration types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
string type_url = 6;
- Specified by:
getTypeUrl
in interfaceFieldOrBuilder
- Returns:
- The typeUrl.
-
getTypeUrlBytes
The field type URL, without the scheme, for message or enumeration types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
string type_url = 6;
- Specified by:
getTypeUrlBytes
in interfaceFieldOrBuilder
- Returns:
- The bytes for typeUrl.
-
setTypeUrl
The field type URL, without the scheme, for message or enumeration types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
string type_url = 6;
- Parameters:
value
- The typeUrl to set.- Returns:
- This builder for chaining.
-
clearTypeUrl
The field type URL, without the scheme, for message or enumeration types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
string type_url = 6;
- Returns:
- This builder for chaining.
-
setTypeUrlBytes
The field type URL, without the scheme, for message or enumeration types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
string type_url = 6;
- Parameters:
value
- The bytes for typeUrl to set.- Returns:
- This builder for chaining.
-
getOneofIndex
public int getOneofIndex()The index of the field type in `Type.oneofs`, for message or enumeration types. The first type has index 1; zero means the type is not in the list.
int32 oneof_index = 7;
- Specified by:
getOneofIndex
in interfaceFieldOrBuilder
- Returns:
- The oneofIndex.
-
setOneofIndex
The index of the field type in `Type.oneofs`, for message or enumeration types. The first type has index 1; zero means the type is not in the list.
int32 oneof_index = 7;
- Parameters:
value
- The oneofIndex to set.- Returns:
- This builder for chaining.
-
clearOneofIndex
The index of the field type in `Type.oneofs`, for message or enumeration types. The first type has index 1; zero means the type is not in the list.
int32 oneof_index = 7;
- Returns:
- This builder for chaining.
-
getPacked
public boolean getPacked()Whether to use alternative packed wire representation.
bool packed = 8;
- Specified by:
getPacked
in interfaceFieldOrBuilder
- Returns:
- The packed.
-
setPacked
Whether to use alternative packed wire representation.
bool packed = 8;
- Parameters:
value
- The packed to set.- Returns:
- This builder for chaining.
-
clearPacked
Whether to use alternative packed wire representation.
bool packed = 8;
- Returns:
- This builder for chaining.
-
ensureOptionsIsMutable
private void ensureOptionsIsMutable() -
getOptionsList
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
- Specified by:
getOptionsList
in interfaceFieldOrBuilder
-
getOptionsCount
public int getOptionsCount()The protocol buffer options.
repeated .google.protobuf.Option options = 9;
- Specified by:
getOptionsCount
in interfaceFieldOrBuilder
-
getOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
- Specified by:
getOptions
in interfaceFieldOrBuilder
-
setOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
setOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
addOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
addOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
addOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
addOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
addAllOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
clearOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
removeOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
getOptionsBuilder
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
getOptionsOrBuilder
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
- Specified by:
getOptionsOrBuilder
in interfaceFieldOrBuilder
-
getOptionsOrBuilderList
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
- Specified by:
getOptionsOrBuilderList
in interfaceFieldOrBuilder
-
addOptionsBuilder
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
addOptionsBuilder
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
getOptionsBuilderList
The protocol buffer options.
repeated .google.protobuf.Option options = 9;
-
getOptionsFieldBuilder
-
getJsonName
The field JSON name.
string json_name = 10;
- Specified by:
getJsonName
in interfaceFieldOrBuilder
- Returns:
- The jsonName.
-
getJsonNameBytes
The field JSON name.
string json_name = 10;
- Specified by:
getJsonNameBytes
in interfaceFieldOrBuilder
- Returns:
- The bytes for jsonName.
-
setJsonName
The field JSON name.
string json_name = 10;
- Parameters:
value
- The jsonName to set.- Returns:
- This builder for chaining.
-
clearJsonName
The field JSON name.
string json_name = 10;
- Returns:
- This builder for chaining.
-
setJsonNameBytes
The field JSON name.
string json_name = 10;
- Parameters:
value
- The bytes for jsonName to set.- Returns:
- This builder for chaining.
-
getDefaultValue
The string value of the default value of this field. Proto2 syntax only.
string default_value = 11;
- Specified by:
getDefaultValue
in interfaceFieldOrBuilder
- Returns:
- The defaultValue.
-
getDefaultValueBytes
The string value of the default value of this field. Proto2 syntax only.
string default_value = 11;
- Specified by:
getDefaultValueBytes
in interfaceFieldOrBuilder
- Returns:
- The bytes for defaultValue.
-
setDefaultValue
The string value of the default value of this field. Proto2 syntax only.
string default_value = 11;
- Parameters:
value
- The defaultValue to set.- Returns:
- This builder for chaining.
-
clearDefaultValue
The string value of the default value of this field. Proto2 syntax only.
string default_value = 11;
- Returns:
- This builder for chaining.
-
setDefaultValueBytes
The string value of the default value of this field. Proto2 syntax only.
string default_value = 11;
- Parameters:
value
- The bytes for defaultValue to set.- Returns:
- This builder for chaining.
-
setUnknownFields
Description copied from interface:Message.Builder
Set theUnknownFieldSet
for this message.- Specified by:
setUnknownFields
in interfaceMessage.Builder
- Overrides:
setUnknownFields
in classGeneratedMessageV3.Builder<Field.Builder>
-
mergeUnknownFields
Description copied from interface:Message.Builder
Merge some unknown fields into theUnknownFieldSet
for this message.- Specified by:
mergeUnknownFields
in interfaceMessage.Builder
- Overrides:
mergeUnknownFields
in classGeneratedMessageV3.Builder<Field.Builder>
-