# Class UnknownFieldSet (3.19.4)

    public final class UnknownFieldSet implements MessageLite

`UnknownFieldSet` keeps track of fields which were seen when parsing a protocol
message but whose field numbers or types are unrecognized. This most frequently occurs when new
fields are added to a message type and then messages containing those fields are read by old
software that was compiled before the new types were added.

Every [Message](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Message) contains an `UnknownFieldSet` (and every [Message.Builder](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Message.Builder)
contains a Builder).

Most users will never need to use this class.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> UnknownFieldSet

## Implements

[MessageLite](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### getDefaultInstance()

    public static UnknownFieldSet getDefaultInstance()

Get an empty `UnknownFieldSet`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |   |

### newBuilder()

    public static UnknownFieldSet.Builder newBuilder()

Create a new Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet.Builder` |   |

### newBuilder(UnknownFieldSet copyFrom)

    public static UnknownFieldSet.Builder newBuilder(UnknownFieldSet copyFrom)

Create a new Builder and initialize it to be a copy of `copyFrom`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `copyFrom` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet.Builder` |   |

### parseFrom(byte\[\] data)

    public static UnknownFieldSet parseFrom(byte[] data)

Parse `data` as an `UnknownFieldSet` and return it.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `data` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.InvalidProtocolBufferException` |   |

### parseFrom(ByteString data)

    public static UnknownFieldSet parseFrom(ByteString data)

Parse `data` as an `UnknownFieldSet` and return it.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `data` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.InvalidProtocolBufferException` |   |

### parseFrom(CodedInputStream input)

    public static UnknownFieldSet parseFrom(CodedInputStream input)

Parse an `UnknownFieldSet` from the given input stream.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `input` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.CodedInputStream` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### parseFrom(InputStream input)

    public static UnknownFieldSet parseFrom(InputStream input)

Parse an `UnknownFieldSet` from `input` and return it.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `input` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

## Methods

### asMap()

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

Get a map of fields in the set by number.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html,https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet.Field>` |   |

### equals(Object other)

    public boolean equals(Object other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)

### 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** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet` |   |

### getField(int number)

    public UnknownFieldSet.Field getField(int number)

Get a field by number. Returns an empty field if not present. Never returns `null`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `number` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet.Field` |   |

### getParserForType()

    public final UnknownFieldSet.Parser getParserForType()

Gets the parser for a message of the same type as this message.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet.Parser` |   |

### getSerializedSize()

    public int getSerializedSize()

Get the number of bytes required to encode this set.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getSerializedSizeAsMessageSet()

    public int getSerializedSizeAsMessageSet()

Get the number of bytes required to encode this set using `MessageSet` wire format.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### hasField(int number)

    public boolean hasField(int number)

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

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `number` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### hashCode()

    public int hashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)

### 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()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageOrBuilder#com_google_protobuf_MessageOrBuilder_getInitializationErrorString__)

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### newBuilderForType()

    public UnknownFieldSet.Builder newBuilderForType()

Constructs a new builder for a message of the same type as this message.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet.Builder` |   |

### toBuilder()

    public UnknownFieldSet.Builder toBuilder()

Constructs a builder initialized with the current message. Use this to derive a new message
from the current one.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet.Builder` |   |

### toByteArray()

    public byte[] toByteArray()

Serializes the message to a `byte` array and returns it. This is just a trivial wrapper
around [#writeTo(CodedOutputStream)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet#com_google_protobuf_UnknownFieldSet_writeTo_com_google_protobuf_CodedOutputStream_).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html[]` |   |

### toByteString()

    public ByteString toByteString()

Serializes the message to a `ByteString` and returns it. This is just a trivial wrapper
around [#writeTo(CodedOutputStream)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet#com_google_protobuf_UnknownFieldSet_writeTo_com_google_protobuf_CodedOutputStream_).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString` |   |

### toString()

    public String toString()

Converts the set to a string in protocol buffer text format. This is just a trivial wrapper
around [TextFormat.Printer#printToString(UnknownFieldSet)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.TextFormat.Printer#com_google_protobuf_TextFormat_Printer_printToString_com_google_protobuf_UnknownFieldSet_).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

**Overrides** [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)

### writeAsMessageSetTo(CodedOutputStream output)

    public void writeAsMessageSetTo(CodedOutputStream output)

Serializes the set and writes it to `output` using `MessageSet` wire format.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `output` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.CodedOutputStream` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### writeDelimitedTo(OutputStream output)

    public void writeDelimitedTo(OutputStream output)

Like [#writeTo(OutputStream)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet#com_google_protobuf_UnknownFieldSet_writeTo_java_io_OutputStream_), but writes the size of the message as a varint before
writing the data. This allows more data to be written to the stream after the message without
the need to delimit the message data yourself. Use Builder#mergeDelimitedFrom(InputStream) (or the static method `
YourMessageType.parseDelimitedFrom(InputStream)`) to parse messages written by this method.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `output` | `https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### writeTo(CodedOutputStream output)

    public void writeTo(CodedOutputStream output)

Serializes the set and writes it to `output`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `output` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.CodedOutputStream` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### writeTo(OutputStream output)

    public void writeTo(OutputStream output)

Serializes the message and writes it to `output`. This is just a trivial wrapper around
[#writeTo(CodedOutputStream)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.UnknownFieldSet#com_google_protobuf_UnknownFieldSet_writeTo_com_google_protobuf_CodedOutputStream_).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `output` | `https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |