# Class AbstractMessage (3.19.4)

    public abstract class AbstractMessage extends AbstractMessageLite implements Message

A partial implementation of the [Message](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Message) interface which implements as many methods of
that interface as possible in terms of other methods.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> [AbstractMessageLite](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite) \> AbstractMessage

## Implements

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

## Inherited Members

[AbstractMessageLite.\<T\>addAll(Iterable\<T\>,Collection\<? super T\>)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite__T_addAll_java_lang_Iterable_T__java_util_Collection___super_T__) [AbstractMessageLite.\<T\>addAll(Iterable\<T\>,List\<? super T\>)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite__T_addAll_java_lang_Iterable_T__java_util_List___super_T__) [AbstractMessageLite.checkByteStringIsUtf8(ByteString)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_checkByteStringIsUtf8_com_google_protobuf_ByteString_) [AbstractMessageLite.toByteArray()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_toByteArray__) [AbstractMessageLite.toByteString()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_toByteString__) [AbstractMessageLite.writeDelimitedTo(OutputStream)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_writeDelimitedTo_java_io_OutputStream_) [AbstractMessageLite.writeTo(OutputStream)](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_writeTo_java_io_OutputStream_) [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

### hashBoolean(boolean b) (deprecated)

    protected static int hashBoolean(boolean b)

**Deprecated.** *from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
generated code.*

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

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

### hashEnum(Internal.EnumLite e) (deprecated)

    protected static int hashEnum(Internal.EnumLite e)

**Deprecated.** *from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
generated code.*

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `e` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Internal.EnumLite` |

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

### hashEnumList(List\<? extends Internal.EnumLite\> list) (deprecated)

    protected static int hashEnumList(List<? extends Internal.EnumLite> list)

**Deprecated.** *from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
generated code.*

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `list` | `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<? extends com.google.protobuf.Internal.EnumLite>` |

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

### hashFields(int hash, Map\<Descriptors.FieldDescriptor,Object\> map)

    protected static int hashFields(int hash, Map<Descriptors.FieldDescriptor,Object> map)

Get a hash code for given fields and values, using the given seed.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `hash` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |
| `map` | `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FieldDescriptor,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` |   |

### hashLong(long n) (deprecated)

    protected static int hashLong(long n)

**Deprecated.** *from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
generated code.*

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

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

## Constructors

### AbstractMessage()

    public AbstractMessage()

## Fields

### memoizedSize

    protected int memoizedSize

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

## Methods

### equals(Object other)

    public boolean equals(Object other)

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.

| **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-)

### findInitializationErrors()

    public List<String> findInitializationErrors()

Returns a list of field paths (e.g. "foo.bar.baz") of required fields which are not set in this
message. You should call [MessageLiteOrBuilder#isInitialized()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLiteOrBuilder#com_google_protobuf_MessageLiteOrBuilder_isInitialized__) first to check if there
are any missing fields, as that method is likely to be much faster than this one even when the
message is fully-initialized.

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

### getInitializationErrorString()

    public String getInitializationErrorString()

Returns a comma-delimited list of required fields which are not set in this message object. You
should call [MessageLiteOrBuilder#isInitialized()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLiteOrBuilder#com_google_protobuf_MessageLiteOrBuilder_isInitialized__) first to check if there are any
missing fields, as that method is likely to be much faster than this one even when the message
is fully-initialized.

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

### getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)

    public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)

TODO(jieluo): Clear it when all subclasses have implemented this method.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `oneof` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.OneofDescriptor` |

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

### getSerializedSize()

    public int getSerializedSize()

Get the number of bytes required to encode this message. The result is only computed on the
first call and memoized after that.

If this message requires more than Integer.MAX_VALUE bytes to encode, the return value will
be smaller than the actual number of bytes required and might be negative.

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

### hasOneof(Descriptors.OneofDescriptor oneof)

    public boolean hasOneof(Descriptors.OneofDescriptor oneof)

TODO(jieluo): Clear it when all subclasses have implemented this method.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `oneof` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.OneofDescriptor` |

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

### hashCode()

    public int hashCode()

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.

| **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(AbstractMessage.BuilderParent parent)

    protected Message.Builder newBuilderForType(AbstractMessage.BuilderParent parent)

Create a nested builder.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessage.BuilderParent` |

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

### toString()

    public final String toString()

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

| **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--)

### writeTo(CodedOutputStream output)

    public void writeTo(CodedOutputStream output)

Serializes the message and writes it to `output`. This does not flush or close the
stream.

| **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` |   |