Class Field.Builder
java.lang.Object
- All Implemented Interfaces:
FieldOrBuilder, Message.Builder, MessageLite.Builder, MessageLiteOrBuilder, MessageOrBuilder, Cloneable
- Enclosing class:
Field
public static final class Field.Builder
extends GeneratedMessage.Builder<Field.Builder>
implements FieldOrBuilder
A single field of a message type. New usages of this message as an alternative to FieldDescriptorProto are strongly discouraged. This message does not reliability preserve all information necessary to model the schema and preserve semantics. Instead make use of FileDescriptorSet which preserves the necessary information.Protobuf type
google.protobuf.Field-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMessageLite.Builder
AbstractMessageLite.Builder.LimitedInputStream -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate intprivate Objectprivate Objectprivate intprivate Objectprivate intprivate intprivate RepeatedFieldBuilder<Option, Option.Builder, OptionOrBuilder> private booleanprivate Object -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateBuilder()privateBuilder(AbstractMessage.BuilderParent parent) -
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.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.private voidbuildPartial0(Field result) private voidbuildPartialRepeatedFields(Field result) 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.The field JSON name.The field type.The field name.The field number.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.private voidThe field cardinality.intThe 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.DescriptorGet the message's type's descriptor.The field JSON name.The field JSON name.getKind()The field type.intThe field type.getName()The field name.The field name.intThe field number.intThe 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.intThe protocol buffer options.The protocol buffer options.getOptionsOrBuilder(int index) The protocol buffer options.List<? extends OptionOrBuilder> The protocol buffer options.booleanWhether 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 GeneratedMessage.FieldAccessorTableGet the FieldAccessorTable for this type.private RepeatedFieldBuilder<Option, Option.Builder, OptionOrBuilder> final booleanReturns 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.Mergeotherinto the message being built.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.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.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.Methods inherited from class GeneratedMessage.Builder
addRepeatedField, clearField, clearOneof, clone, dispose, getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getParentForChildren, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, getUnknownFieldSetBuilder, hasField, hasOneof, internalGetMapField, internalGetMapFieldReflection, internalGetMutableMapField, internalGetMutableMapFieldReflection, isClean, markClean, mergeUnknownFields, mergeUnknownLengthDelimitedField, mergeUnknownVarintField, newBuilderForField, onBuilt, onChanged, parseUnknownField, setField, setRepeatedField, setUnknownFields, setUnknownFieldSetBuilder, setUnknownFieldsProto3Methods inherited from class AbstractMessage.Builder
findInitializationErrors, getInitializationErrorString, internalMergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toStringMethods inherited from class AbstractMessageLite.Builder
addAll, addAll, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, newUninitializedMessageExceptionMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Message.Builder
mergeDelimitedFrom, mergeDelimitedFromMethods inherited from interface MessageLite.Builder
mergeFromMethods inherited from interface 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:GeneratedMessage.BuilderGet 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:
internalGetFieldAccessorTablein classGeneratedMessage.Builder<Field.Builder>
-
clear
Description copied from class:GeneratedMessage.BuilderCalled by the initialization and clear code paths to allow subclasses to reset any of their builtin fields back to the initial values.- Specified by:
clearin interfaceMessage.Builder- Specified by:
clearin interfaceMessageLite.Builder- Overrides:
clearin classGeneratedMessage.Builder<Field.Builder>
-
getDescriptorForType
Description copied from interface:Message.BuilderGet the message's type's descriptor. SeeMessageOrBuilder.getDescriptorForType().- Specified by:
getDescriptorForTypein interfaceMessage.Builder- Specified by:
getDescriptorForTypein interfaceMessageOrBuilder- Overrides:
getDescriptorForTypein classGeneratedMessage.Builder<Field.Builder>
-
getDefaultInstanceForType
Description copied from interface:MessageLiteOrBuilderGet 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 theMessageLiteinterface whereasgetDefaultInstance()is a static method of a specific class. They return the same thing.- Specified by:
getDefaultInstanceForTypein interfaceMessageLiteOrBuilder- Specified by:
getDefaultInstanceForTypein interfaceMessageOrBuilder
-
build
Description copied from interface:MessageLite.BuilderConstructs the message based on the state of the Builder. Subsequent changes to the Builder will not affect the returned message.- Specified by:
buildin interfaceMessage.Builder- Specified by:
buildin interfaceMessageLite.Builder
-
buildPartial
Description copied from interface:MessageLite.BuilderLikeMessageLite.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:
buildPartialin interfaceMessage.Builder- Specified by:
buildPartialin interfaceMessageLite.Builder
-
buildPartialRepeatedFields
-
buildPartial0
-
mergeFrom
Description copied from interface:Message.BuilderMergeotherinto the message being built.othermust 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 inotherare 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::MergeFrommethod in C++.- Specified by:
mergeFromin interfaceMessage.Builder- Overrides:
mergeFromin classAbstractMessage.Builder<Field.Builder>
-
mergeFrom
-
isInitialized
public final boolean isInitialized()Description copied from interface:MessageLiteOrBuilderReturns true if all required fields in the message and all embedded messages are set, false otherwise.- Specified by:
isInitializedin interfaceMessageLiteOrBuilder- Overrides:
isInitializedin classGeneratedMessage.Builder<Field.Builder>
-
mergeFrom
public Field.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:MessageLite.BuilderLikeMessageLite.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:
mergeFromin interfaceMessage.Builder- Specified by:
mergeFromin interfaceMessageLite.Builder- Overrides:
mergeFromin classAbstractMessage.Builder<Field.Builder>- Throws:
IOException- an I/O error reading from the stream
-
getKindValue
public int getKindValue()The field type.
.google.protobuf.Field.Kind kind = 1;- Specified by:
getKindValuein 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.
- Throws:
IllegalArgumentException- if UNRECOGNIZED is provided.
-
getKind
The field type.
.google.protobuf.Field.Kind kind = 1;- Specified by:
getKindin 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:
getCardinalityValuein 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.
- Throws:
IllegalArgumentException- if UNRECOGNIZED is provided.
-
getCardinality
The field cardinality.
.google.protobuf.Field.Cardinality cardinality = 2;- Specified by:
getCardinalityin 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:
getNumberin 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:
getNamein interfaceFieldOrBuilder- Returns:
- The name.
-
getNameBytes
The field name.
string name = 4;- Specified by:
getNameBytesin 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:
getTypeUrlin 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:
getTypeUrlBytesin 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:
getOneofIndexin 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:
getPackedin 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:
getOptionsListin interfaceFieldOrBuilder
-
getOptionsCount
public int getOptionsCount()The protocol buffer options.
repeated .google.protobuf.Option options = 9;- Specified by:
getOptionsCountin interfaceFieldOrBuilder
-
getOptions
The protocol buffer options.
repeated .google.protobuf.Option options = 9;- Specified by:
getOptionsin 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:
getOptionsOrBuilderin interfaceFieldOrBuilder
-
getOptionsOrBuilderList
The protocol buffer options.
repeated .google.protobuf.Option options = 9;- Specified by:
getOptionsOrBuilderListin 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; -
internalGetOptionsFieldBuilder
private RepeatedFieldBuilder<Option, Option.Builder, OptionOrBuilder> internalGetOptionsFieldBuilder() -
getJsonName
The field JSON name.
string json_name = 10;- Specified by:
getJsonNamein interfaceFieldOrBuilder- Returns:
- The jsonName.
-
getJsonNameBytes
The field JSON name.
string json_name = 10;- Specified by:
getJsonNameBytesin 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:
getDefaultValuein interfaceFieldOrBuilder- Returns:
- The defaultValue.
-
getDefaultValueBytes
The string value of the default value of this field. Proto2 syntax only.
string default_value = 11;- Specified by:
getDefaultValueBytesin 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.
-