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.
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.
Parses a message of this type from the input and merges it with this message.
Warning: This does not verify that all required fields are present in the input message.
If you call #build() without setting all required fields, it will throw an UninitializedMessageException, which is a RuntimeException and thus might not be
caught. There are a few good ways to deal with this:
Call #isInitialized() to verify that all required fields are set before
building.
Use buildPartial() to build, which ignores missing required fields.
Note: The caller should call CodedInputStream#checkLastTagWas(int) after calling
this to verify that the last tag seen was the appropriate end-group tag, or zero for EOF.
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.
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++.
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). Note that this
method always reads the entire input (unless it throws an exception). If you want it
to stop earlier, you will need to wrap your input in some wrapper stream that limits reading.
Or, use MessageLite#writeDelimitedTo(OutputStream) to write your message and #mergeDelimitedFrom(InputStream) to read it.
Despite usually reading the entire input, this does not close the stream.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Interface MessageLite.Builder (3.19.4)\n\n public static interface MessageLite.Builder extends MessageLiteOrBuilder, Cloneable\n\nAbstract interface implemented by Protocol Message builders. \n\nImplements\n----------\n\n[MessageLiteOrBuilder](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLiteOrBuilder), [Cloneable](https://docs.oracle.com/javase/8/docs/api/java/lang/Cloneable.html)\n\nMethods\n-------\n\n### build()\n\n public abstract MessageLite build()\n\nConstructs the message based on the state of the Builder. Subsequent changes to the Builder\nwill not affect the returned message.\n\n### buildPartial()\n\n public abstract MessageLite buildPartial()\n\nLike [#build()](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_build__), but does not throw an exception if the message is missing required\nfields. Instead, a partial message is returned. Subsequent changes to the Builder will not\naffect the returned message.\n\n### clear()\n\n public abstract MessageLite.Builder clear()\n\nResets all fields to their default values.\n\n### clone()\n\n public abstract MessageLite.Builder clone()\n\nClones the Builder.\n**See Also:** [Object#clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--)\n\n### mergeDelimitedFrom(InputStream input)\n\n public abstract boolean mergeDelimitedFrom(InputStream input)\n\nLike [#mergeFrom(InputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeFrom_java_io_InputStream_), but does not read until EOF. Instead, the size of the\nmessage (encoded as a varint) is read first, then the message data. Use [MessageLite#writeDelimitedTo(OutputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite#com_google_protobuf_MessageLite_writeDelimitedTo_java_io_OutputStream_) to write messages in this format.\n\n### mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)\n\n public abstract boolean mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)\n\nLike [#mergeDelimitedFrom(InputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeDelimitedFrom_java_io_InputStream_) but supporting extensions.\n\n### mergeFrom(byte\\[\\] data)\n\n public abstract MessageLite.Builder mergeFrom(byte[] data)\n\nParse `data` as a message of this type and merge it with the message being built. This\nis just a small wrapper around [#mergeFrom(CodedInputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeFrom_com_google_protobuf_CodedInputStream_).\n\n### mergeFrom(byte\\[\\] data, ExtensionRegistryLite extensionRegistry)\n\n public abstract MessageLite.Builder mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry)\n\nParse `data` as a message of this type and merge it with the message being built. This\nis just a small wrapper around [#mergeFrom(CodedInputStream,ExtensionRegistryLite)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeFrom_com_google_protobuf_CodedInputStream_com_google_protobuf_ExtensionRegistryLite_).\n\n### mergeFrom(byte\\[\\] data, int off, int len)\n\n public abstract MessageLite.Builder mergeFrom(byte[] data, int off, int len)\n\nParse `data` as a message of this type and merge it with the message being built. This\nis just a small wrapper around [#mergeFrom(CodedInputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeFrom_com_google_protobuf_CodedInputStream_).\n\n### mergeFrom(byte\\[\\] data, int off, int len, ExtensionRegistryLite extensionRegistry)\n\n public abstract MessageLite.Builder mergeFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)\n\nParse `data` as a message of this type and merge it with the message being built. This\nis just a small wrapper around [#mergeFrom(CodedInputStream,ExtensionRegistryLite)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeFrom_com_google_protobuf_CodedInputStream_com_google_protobuf_ExtensionRegistryLite_).\n\n### mergeFrom(ByteString data)\n\n public abstract MessageLite.Builder mergeFrom(ByteString data)\n\nParse `data` as a message of this type and merge it with the message being built. This\nis just a small wrapper around [#mergeFrom(CodedInputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeFrom_com_google_protobuf_CodedInputStream_).\n\n### mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry)\n\n public abstract MessageLite.Builder mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry)\n\nParse `data` as a message of this type and merge it with the message being built. This\nis just a small wrapper around [#mergeFrom(CodedInputStream,ExtensionRegistryLite)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeFrom_com_google_protobuf_CodedInputStream_com_google_protobuf_ExtensionRegistryLite_).\n\n### mergeFrom(CodedInputStream input)\n\n public abstract MessageLite.Builder mergeFrom(CodedInputStream input)\n\nParses a message of this type from the input and merges it with this message.\n\nWarning: This does not verify that all required fields are present in the input message.\nIf you call [#build()](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_build__) without setting all required fields, it will throw an [UninitializedMessageException](/java/docs/reference/protobuf/latest/com.google.protobuf.UninitializedMessageException), which is a `RuntimeException` and thus might not be\ncaught. There are a few good ways to deal with this:\n\n- Call #isInitialized() to verify that all required fields are set before building.\n- Use `buildPartial()` to build, which ignores missing required fields.\n\nNote: The caller should call [CodedInputStream#checkLastTagWas(int)](/java/docs/reference/protobuf/latest/com.google.protobuf.CodedInputStream#com_google_protobuf_CodedInputStream_checkLastTagWas_int_) after calling\nthis to verify that the last tag seen was the appropriate end-group tag, or zero for EOF.\n\n### mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)\n\n public abstract MessageLite.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)\n\nLike Builder#mergeFrom(CodedInputStream), but also parses extensions. The extensions\nthat you want to be able to parse must be registered in `extensionRegistry`. Extensions\nnot in the registry will be treated as unknown fields.\n\n### mergeFrom(MessageLite other)\n\n public abstract MessageLite.Builder mergeFrom(MessageLite other)\n\nMerge `other` into the message being built. `other` must have the exact same type\nas `this` (i.e. `getClass().equals(getDefaultInstanceForType().getClass())`).\n\nMerging occurs as follows. For each field: \n\n- For singular primitive fields, if the field is set in `other`, then `other`'s value overwrites the value in this message. \n- 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. \n- For repeated fields, the elements in `other` are concatenated with the elements in\n this message. \\* For oneof groups, if the other message has one of the fields set, the group\n of this message is cleared and replaced by the field of the other message, so that the oneof\n constraint is preserved.\n\n \u003cbr /\u003e\n\n This is equivalent to the `Message::MergeFrom` method in C++.\n\n### mergeFrom(InputStream input)\n\n public abstract MessageLite.Builder mergeFrom(InputStream input)\n\nParse a message of this type from `input` and merge it with the message being built.\nThis is just a small wrapper around [#mergeFrom(CodedInputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeFrom_com_google_protobuf_CodedInputStream_). Note that this\nmethod always reads the *entire* input (unless it throws an exception). If you want it\nto stop earlier, you will need to wrap your input in some wrapper stream that limits reading.\nOr, use [MessageLite#writeDelimitedTo(OutputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite#com_google_protobuf_MessageLite_writeDelimitedTo_java_io_OutputStream_) to write your message and [#mergeDelimitedFrom(InputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeDelimitedFrom_java_io_InputStream_) to read it.\n\nDespite usually reading the entire input, this does not close the stream.\n\n### mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry)\n\n public abstract MessageLite.Builder mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry)\n\nParse a message of this type from `input` and merge it with the message being built.\nThis is just a small wrapper around [#mergeFrom(CodedInputStream,ExtensionRegistryLite)](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite.Builder#com_google_protobuf_MessageLite_Builder_mergeFrom_com_google_protobuf_CodedInputStream_com_google_protobuf_ExtensionRegistryLite_)."]]