com.google.protobuf

## Class UnknownFieldSet.Builder

- java.lang.Object
- - com.google.protobuf.UnknownFieldSet.Builder

- All Implemented Interfaces:
    MessageLite.Builder, MessageLiteOrBuilder, java.lang.Cloneable
  Enclosing class:
    UnknownFieldSet

      public static final class UnknownFieldSet.Builder
      extends java.lang.Object
      implements MessageLite.Builder

  Builder for `UnknownFieldSet`s.

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

  Use `UnknownFieldSet.newBuilder()` to construct a `Builder`.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `UnknownFieldSet.Builder` | `addField(int number, UnknownFieldSet.Field field)` Add a field to the `UnknownFieldSet`.
    `java.util.Map<java.lang.Integer,UnknownFieldSet.Field>` | `asMap()` Get all present `Field`s as an immutable `Map`.
    `UnknownFieldSet` | `build()` Build the `UnknownFieldSet` and return it.
    `UnknownFieldSet` | `buildPartial()` Like `MessageLite.Builder.build()`, but does not throw an exception if the message is missing required fields.
    `UnknownFieldSet.Builder` | `clear()` Reset the builder to an empty set.
    `UnknownFieldSet.Builder` | `clearField(int number)` Clear fields from the set with a given field number.
    `UnknownFieldSet.Builder` | `clone()` Clones the Builder.
    `UnknownFieldSet` | `getDefaultInstanceForType()` Get an instance of the type with no fields set.
    `boolean` | `hasField(int number)` Check if the given field number is present in the set.
    `boolean` | `isInitialized()` Returns true if all required fields in the message and all embedded messages are set, false otherwise.
    `boolean` | `mergeDelimitedFrom(java.io.InputStream input)` Like `MessageLite.Builder.mergeFrom(InputStream)`, but does not read until EOF.
    `boolean` | `mergeDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)` Like `MessageLite.Builder.mergeDelimitedFrom(InputStream)` but supporting extensions.
    `UnknownFieldSet.Builder` | `mergeField(int number, UnknownFieldSet.Field field)` Add a field to the `UnknownFieldSet`.
    `boolean` | `mergeFieldFrom(int tag, CodedInputStream input)` Parse a single field from `input` and merge it into this set.
    `UnknownFieldSet.Builder` | `mergeFrom(byte[] data)` Parse `data` as an `UnknownFieldSet` and merge it with the set being built.
    `UnknownFieldSet.Builder` | `mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry)` Parse `data` as a message of this type and merge it with the message being built.
    `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.
    `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.
    `UnknownFieldSet.Builder` | `mergeFrom(ByteString data)` Parse `data` as an `UnknownFieldSet` and merge it with the set being built.
    `UnknownFieldSet.Builder` | `mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry)` Parse `data` as a message of this type and merge it with the message being built.
    `UnknownFieldSet.Builder` | `mergeFrom(CodedInputStream input)` Parse an entire message from `input` and merge its fields into this set.
    `UnknownFieldSet.Builder` | `mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)` Like `MessageLite.Builder.mergeFrom(CodedInputStream)`, but also parses extensions.
    `UnknownFieldSet.Builder` | `mergeFrom(java.io.InputStream input)` Parse an `UnknownFieldSet` from `input` and merge it with the set being built.
    `UnknownFieldSet.Builder` | `mergeFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)` Parse a message of this type from `input` and merge it with the message being built.
    `UnknownFieldSet.Builder` | `mergeFrom(MessageLite m)` Merge `other` into the message being built.
    `UnknownFieldSet.Builder` | `mergeFrom(UnknownFieldSet other)` Merge the fields from `other` into this set.
    `UnknownFieldSet.Builder` | `mergeLengthDelimitedField(int number, ByteString value)` Convenience method for merging a length-delimited field.
    `UnknownFieldSet.Builder` | `mergeVarintField(int number, int value)` Convenience method for merging a new field containing a single varint value.

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### build

          public UnknownFieldSet build()

      Build the `UnknownFieldSet` and return it.

      Once `build()` has been called, the `Builder` will no longer be usable. Calling any method after `build()` will result in undefined behavior and can cause a `NullPointerException` to be thrown.

      Specified by:
        `build` in interface `MessageLite.Builder`

    - #### buildPartial

          public UnknownFieldSet buildPartial()

      Description copied from interface: `MessageLite.Builder`
      Like `MessageLite.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 interface `MessageLite.Builder`

    - #### clone

          public UnknownFieldSet.Builder clone()

      Description copied from interface: `MessageLite.Builder`
      Clones the Builder.
      Specified by:
        `clone` in interface `MessageLite.Builder`
      Overrides:
        `clone` in class `java.lang.Object`
      See Also:
        `Object.clone()`

    - #### getDefaultInstanceForType

          public UnknownFieldSet 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 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.
      Specified by:
        `getDefaultInstanceForType` in interface `MessageLiteOrBuilder`

    - #### clear

          public UnknownFieldSet.Builder clear()

      Reset the builder to an empty set.
      Specified by:
        `clear` in interface `MessageLite.Builder`

    - #### clearField

          public UnknownFieldSet.Builder clearField(int number)

      Clear fields from the set with a given field number.

    - #### mergeFrom

          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.

    - #### mergeField

          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.

    - #### mergeVarintField

          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.

    - #### mergeLengthDelimitedField

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

      Convenience method for merging a length-delimited field.

      For use by generated code only.

    - #### hasField

          public boolean hasField(int number)

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

    - #### addField

          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.

    - #### asMap

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

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

    - #### mergeFrom

          public UnknownFieldSet.Builder mergeFrom(CodedInputStream input)
                                            throws java.io.IOException

      Parse an entire message from `input` and merge its fields into this set.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Throws:
        `java.io.IOException`

    - #### mergeFieldFrom

          public boolean mergeFieldFrom(int tag,
                               CodedInputStream input)
                                 throws java.io.IOException

      Parse a single field from `input` and merge it into this set.
      Parameters:
        `tag` - The field's tag number, which was already parsed.
      Returns:
        `false` if the tag is an end group tag.
      Throws:
        `java.io.IOException`

    - #### mergeFrom

          public UnknownFieldSet.Builder mergeFrom(ByteString data)
                                            throws InvalidProtocolBufferException

      Parse `data` as an `UnknownFieldSet` and merge it with the set being built. This is just a small wrapper around `mergeFrom(CodedInputStream)`.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Returns:
        this
      Throws:
        `InvalidProtocolBufferException`

    - #### mergeFrom

          public UnknownFieldSet.Builder mergeFrom(byte[] data)
                                            throws InvalidProtocolBufferException

      Parse `data` as an `UnknownFieldSet` and merge it with the set being built. This is just a small wrapper around `mergeFrom(CodedInputStream)`.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Returns:
        this
      Throws:
        `InvalidProtocolBufferException`

    - #### mergeFrom

          public UnknownFieldSet.Builder mergeFrom(java.io.InputStream input)
                                            throws java.io.IOException

      Parse an `UnknownFieldSet` from `input` and merge it with the set being built. This is just a small wrapper around `mergeFrom(CodedInputStream)`.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Returns:
        this
      Throws:
        `java.io.IOException`

    - #### mergeDelimitedFrom

          public boolean mergeDelimitedFrom(java.io.InputStream input)
                                     throws java.io.IOException

      Description copied from interface: `MessageLite.Builder`
      Like `MessageLite.Builder.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.
      Specified by:
        `mergeDelimitedFrom` in interface `MessageLite.Builder`
      Returns:
        True if successful, or false if the stream is at EOF when the method starts. Any other error (including reaching EOF during parsing) will cause an exception to be thrown.
      Throws:
        `java.io.IOException`

    - #### mergeDelimitedFrom

          public boolean mergeDelimitedFrom(java.io.InputStream input,
                                   ExtensionRegistryLite extensionRegistry)
                                     throws java.io.IOException

      Description copied from interface: `MessageLite.Builder`
      Like `MessageLite.Builder.mergeDelimitedFrom(InputStream)` but supporting extensions.
      Specified by:
        `mergeDelimitedFrom` in interface `MessageLite.Builder`
      Throws:
        `java.io.IOException`

    - #### mergeFrom

          public UnknownFieldSet.Builder mergeFrom(CodedInputStream input,
                                          ExtensionRegistryLite extensionRegistry)
                                            throws java.io.IOException

      Description copied from interface: `MessageLite.Builder`
      Like `MessageLite.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.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Throws:
        `java.io.IOException`

    - #### mergeFrom

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

      Description copied from interface: `MessageLite.Builder`
      Parse `data` as a message of this type and merge it with the message being built. This is just a small wrapper around `MessageLite.Builder.mergeFrom(CodedInputStream,ExtensionRegistryLite)`.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Returns:
        this
      Throws:
        `InvalidProtocolBufferException`

    - #### mergeFrom

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

      Description copied from interface: `MessageLite.Builder`
      Parse `data` as a message of this type and merge it with the message being built. This is just a small wrapper around `MessageLite.Builder.mergeFrom(CodedInputStream)`.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Returns:
        this
      Throws:
        `InvalidProtocolBufferException`

    - #### mergeFrom

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

      Description copied from interface: `MessageLite.Builder`
      Parse `data` as a message of this type and merge it with the message being built. This is just a small wrapper around `MessageLite.Builder.mergeFrom(CodedInputStream,ExtensionRegistryLite)`.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Returns:
        this
      Throws:
        `InvalidProtocolBufferException`

    - #### mergeFrom

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

      Description copied from interface: `MessageLite.Builder`
      Parse `data` as a message of this type and merge it with the message being built. This is just a small wrapper around `MessageLite.Builder.mergeFrom(CodedInputStream,ExtensionRegistryLite)`.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Returns:
        this
      Throws:
        `InvalidProtocolBufferException`

    - #### mergeFrom

          public UnknownFieldSet.Builder mergeFrom(java.io.InputStream input,
                                          ExtensionRegistryLite extensionRegistry)
                                            throws java.io.IOException

      Description copied from interface: `MessageLite.Builder`
      Parse a message of this type from `input` and merge it with the message being built. This is just a small wrapper around `MessageLite.Builder.mergeFrom(CodedInputStream,ExtensionRegistryLite)`.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`
      Returns:
        this
      Throws:
        `java.io.IOException`

    - #### mergeFrom

          public UnknownFieldSet.Builder mergeFrom(MessageLite m)

      Description copied from interface: `MessageLite.Builder`
      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++.
      Specified by:
        `mergeFrom` in interface `MessageLite.Builder`

    - #### isInitialized

          public boolean isInitialized()

      Description copied from interface: `MessageLiteOrBuilder`
      Returns true if all required fields in the message and all embedded messages are set, false otherwise.

      See also: `MessageOrBuilder.getInitializationErrorString()`

      Specified by:
        `isInitialized` in interface `MessageLiteOrBuilder`