Class UnknownFieldSet.Builder (3.19.4)

public static final class UnknownFieldSet.Builder implements MessageLite.Builder

Builder for UnknownFieldSets.

Note that this class maintains Field.Builders for all fields in the set. Thus, adding one element to an existing Field does not require making a copy. This is important for efficient parsing of unknown repeated fields. However, it implies that Fields cannot be constructed independently, nor can two UnknownFieldSets share the same Field object.

Use UnknownFieldSet#newBuilder() to construct a Builder.

Inheritance

java.lang.Object > UnknownFieldSet.Builder

Implements

MessageLite.Builder

Methods

addField(int number, UnknownFieldSet.Field field)

public UnknownFieldSet.Builder addField(int number, UnknownFieldSet.Field field)

Add a field to the UnknownFieldSet. If a field with the same number already exists, it is removed.

Parameters
Name Description
number int
field UnknownFieldSet.Field
Returns
Type Description
UnknownFieldSet.Builder

asMap()

public Map<Integer,UnknownFieldSet.Field> asMap()

Get all present Fields as an immutable Map. If more fields are added, the changes may or may not be reflected in this map.

Returns
Type Description
Map<Integer,Field>

build()

public UnknownFieldSet build()

Build the UnknownFieldSet and return it.

Returns
Type Description
UnknownFieldSet

buildPartial()

public UnknownFieldSet buildPartial()

Like #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.

Returns
Type Description
UnknownFieldSet

clear()

public UnknownFieldSet.Builder clear()

Reset the builder to an empty set.

Returns
Type Description
UnknownFieldSet.Builder

clearField(int number)

public UnknownFieldSet.Builder clearField(int number)

Clear fields from the set with a given field number.

Parameter
Name Description
number int
Returns
Type Description
UnknownFieldSet.Builder

clone()

public UnknownFieldSet.Builder clone()

Clones the Builder.

Returns
Type Description
UnknownFieldSet.Builder
Overrides

getDefaultInstanceForType()

public UnknownFieldSet 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
Type Description
UnknownFieldSet

hasField(int number)

public boolean hasField(int number)

Check if the given field number is present in the set.

Parameter
Name Description
number int
Returns
Type Description
boolean

isInitialized()

public boolean isInitialized()

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

mergeDelimitedFrom(InputStream input)

public boolean mergeDelimitedFrom(InputStream input)

Like #mergeFrom(InputStream), but does not read until EOF. Instead, the size of the message (encoded as a varint) is read first, then the message data. Use MessageLite#writeDelimitedTo(OutputStream) to write messages in this format.

Parameter
Name Description
input InputStream
Returns
Type Description
boolean
Exceptions
Type Description
IOException

mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public boolean mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

Like #mergeDelimitedFrom(InputStream) but supporting extensions.

Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
boolean
Exceptions
Type Description
IOException

mergeField(int number, UnknownFieldSet.Field field)

public UnknownFieldSet.Builder mergeField(int number, UnknownFieldSet.Field field)

Add a field to the UnknownFieldSet. If a field with the same number already exists, the two are merged.

Parameters
Name Description
number int
field UnknownFieldSet.Field
Returns
Type Description
UnknownFieldSet.Builder

mergeFieldFrom(int tag, CodedInputStream input)

public boolean mergeFieldFrom(int tag, CodedInputStream input)

Parse a single field from input and merge it into this set.

Parameters
Name Description
tag int

The field's tag number, which was already parsed.

input CodedInputStream
Returns
Type Description
boolean

false if the tag is an end group tag.

Exceptions
Type Description
IOException

mergeFrom(byte[] data)

public UnknownFieldSet.Builder mergeFrom(byte[] data)

Parse data as an UnknownFieldSet and merge it with the set being built. This is just a small wrapper around #mergeFrom(CodedInputStream).

Parameter
Name Description
data byte[]
Returns
Type Description
UnknownFieldSet.Builder
Exceptions
Type Description
InvalidProtocolBufferException

mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public UnknownFieldSet.Builder mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around #mergeFrom(CodedInputStream,ExtensionRegistryLite).

Parameters
Name Description
data byte[]
extensionRegistry ExtensionRegistryLite
Returns
Type Description
UnknownFieldSet.Builder
Exceptions
Type Description
InvalidProtocolBufferException

mergeFrom(byte[] data, int off, int len)

public UnknownFieldSet.Builder mergeFrom(byte[] data, int off, int len)

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around #mergeFrom(CodedInputStream).

Parameters
Name Description
data byte[]
off int
len int
Returns
Type Description
UnknownFieldSet.Builder
Exceptions
Type Description
InvalidProtocolBufferException

mergeFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

public UnknownFieldSet.Builder mergeFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around #mergeFrom(CodedInputStream,ExtensionRegistryLite).

Parameters
Name Description
data byte[]
off int
len int
extensionRegistry ExtensionRegistryLite
Returns
Type Description
UnknownFieldSet.Builder
Exceptions
Type Description
InvalidProtocolBufferException

mergeFrom(ByteString data)

public UnknownFieldSet.Builder mergeFrom(ByteString data)

Parse data as an UnknownFieldSet and merge it with the set being built. This is just a small wrapper around #mergeFrom(CodedInputStream).

Parameter
Name Description
data ByteString
Returns
Type Description
UnknownFieldSet.Builder
Exceptions
Type Description
InvalidProtocolBufferException

mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public UnknownFieldSet.Builder mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around #mergeFrom(CodedInputStream,ExtensionRegistryLite).

Parameters
Name Description
data ByteString
extensionRegistry ExtensionRegistryLite
Returns
Type Description
UnknownFieldSet.Builder
Exceptions
Type Description
InvalidProtocolBufferException

mergeFrom(CodedInputStream input)

public UnknownFieldSet.Builder mergeFrom(CodedInputStream input)

Parse an entire message from input and merge its fields into this set.

Parameter
Name Description
input CodedInputStream
Returns
Type Description
UnknownFieldSet.Builder
Exceptions
Type Description
IOException

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public UnknownFieldSet.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

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
UnknownFieldSet.Builder
Exceptions
Type Description
IOException

mergeFrom(MessageLite m)

public UnknownFieldSet.Builder mergeFrom(MessageLite m)

Merge other into the message being built. other must have the exact same type as this (i.e. getClass().equals(getDefaultInstanceForType().getClass())).

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
m MessageLite
Returns
Type Description
UnknownFieldSet.Builder

mergeFrom(UnknownFieldSet other)

public UnknownFieldSet.Builder mergeFrom(UnknownFieldSet other)

Merge the fields from other into this set. If a field number exists in both sets, other's values for that field will be appended to the values in this set.

Parameter
Name Description
other UnknownFieldSet
Returns
Type Description
UnknownFieldSet.Builder

mergeFrom(InputStream input)

public UnknownFieldSet.Builder mergeFrom(InputStream input)

Parse an UnknownFieldSet from input and merge it with the set being built. This is just a small wrapper around #mergeFrom(CodedInputStream).

Parameter
Name Description
input InputStream
Returns
Type Description
UnknownFieldSet.Builder
Exceptions
Type Description
IOException

mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public UnknownFieldSet.Builder mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

Parse a message of this type from input and merge it with the message being built. This is just a small wrapper around #mergeFrom(CodedInputStream,ExtensionRegistryLite).

Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
UnknownFieldSet.Builder
Exceptions
Type Description
IOException

mergeLengthDelimitedField(int number, ByteString value)

public UnknownFieldSet.Builder mergeLengthDelimitedField(int number, ByteString value)

Convenience method for merging a length-delimited field.

For use by generated code only.

Parameters
Name Description
number int
value ByteString
Returns
Type Description
UnknownFieldSet.Builder

mergeVarintField(int number, int value)

public UnknownFieldSet.Builder mergeVarintField(int number, int value)

Convenience method for merging a new field containing a single varint value. This is used in particular when an unknown enum value is encountered.

Parameters
Name Description
number int
value int
Returns
Type Description
UnknownFieldSet.Builder