Abstract interface implemented by Protocol Message objects.
See also MessageLite, which defines most of the methods that typical users care about.
Message adds to it methods that are not available in the "lite" runtime. The biggest
added features are introspection and reflection -- i.e., getting descriptors for the message type
and accessing the field values dynamically.
Compares the specified object with this message for equality. Returns true if the given
object is a message of the same type (as defined by getDescriptorForType()) and has
identical values for all of its fields. Subclasses must implement this; inheriting
Object.equals() is incorrect.
Returns the hash code value for this message. The hash code of a message should mix the
message's type (object identity of the descriptor) with its contents (known and unknown field
values). Subclasses must implement this; inheriting Object.hashCode() is incorrect.
See Also:Map#hashCode()
[[["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-08-07 UTC."],[],[],null,["# Interface Message (3.19.4)\n\n public interface Message extends MessageLite, MessageOrBuilder\n\nAbstract interface implemented by Protocol Message objects.\n\nSee also [MessageLite](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite), which defines most of the methods that typical users care about.\nMessage adds to it methods that are not available in the \"lite\" runtime. The biggest\nadded features are introspection and reflection -- i.e., getting descriptors for the message type\nand accessing the field values dynamically. \n\nImplements\n----------\n\n[MessageLite](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite), [MessageOrBuilder](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageOrBuilder)\n\nMethods\n-------\n\n### equals(Object other)\n\n public abstract boolean equals(Object other)\n\nCompares the specified object with this message for equality. Returns `true` if the given\nobject is a message of the same type (as defined by `getDescriptorForType()`) and has\nidentical values for all of its fields. Subclasses must implement this; inheriting `\nObject.equals()` is incorrect.\n\n**Overrides** \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)\n\n### getParserForType()\n\n public abstract Parser\u003c? extends Message\u003e getParserForType()\n\nGets the parser for a message of the same type as this message.\n\n### hashCode()\n\n public abstract int hashCode()\n\nReturns the hash code value for this message. The hash code of a message should mix the\nmessage's type (object identity of the descriptor) with its contents (known and unknown field\nvalues). Subclasses must implement this; inheriting `Object.hashCode()` is incorrect.\n**See Also:** Map#hashCode()\n\n**Overrides** \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)\n\n### newBuilderForType()\n\n public abstract Message.Builder newBuilderForType()\n\nConstructs a new builder for a message of the same type as this message.\n\n### toBuilder()\n\n public abstract Message.Builder toBuilder()\n\nConstructs a builder initialized with the current message. Use this to derive a new message\nfrom the current one.\n\n### toString()\n\n public abstract String toString()\n\nConverts the message to a string in protocol buffer text format. This is just a trivial wrapper\naround [TextFormat.Printer#printToString(MessageOrBuilder)](/java/docs/reference/protobuf/latest/com.google.protobuf.TextFormat.Printer#com_google_protobuf_TextFormat_Printer_printToString_com_google_protobuf_MessageOrBuilder_).\n\n**Overrides** \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)"]]