public abstract class AbstractMessage extends AbstractMessageLite implements Message
Message interface which implements
as many methods of that interface as possible in terms of other methods.| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractMessage.Builder<BuilderType extends AbstractMessage.Builder<BuilderType>>
A partial implementation of the
Message.Builder interface which
implements as many methods of that interface as possible in terms of
other methods. |
protected static interface |
AbstractMessage.BuilderParent
Interface for the parent of a Builder that allows the builder to
communicate invalidations back to the parent for use when using nested
builders.
|
| Modifier and Type | Field and Description |
|---|---|
protected int |
memoizedSize |
memoizedHashCode| Constructor and Description |
|---|
AbstractMessage() |
| Modifier and Type | Method and Description |
|---|---|
private static boolean |
compareBytes(java.lang.Object a,
java.lang.Object b)
Compares two bytes fields.
|
(package private) static boolean |
compareFields(java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> a,
java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> b)
Compares two set of fields.
|
private static boolean |
compareMapField(java.lang.Object a,
java.lang.Object b)
Compares two map fields.
|
private static java.util.Map |
convertMapEntryListToMap(java.util.List list)
Converts a list of MapEntry messages into a Map used for equals() and
hashCode().
|
boolean |
equals(java.lang.Object other)
Compares the specified object with this message for equality.
|
java.util.List<java.lang.String> |
findInitializationErrors()
Returns a list of field paths (e.g.
|
java.lang.String |
getInitializationErrorString()
Returns a comma-delimited list of required fields which are not set
in this message object.
|
(package private) int |
getMemoizedSerializedSize() |
Descriptors.FieldDescriptor |
getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
int |
getSerializedSize()
Get the number of bytes required to encode this message.
|
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.
|
int |
hashCode()
Returns the hash code value for this message.
|
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.
|
protected static int |
hashEnumList(java.util.List<? extends Internal.EnumLite> list)
Deprecated.
from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
generated code.
|
protected static int |
hashFields(int hash,
java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> map)
Get a hash code for given fields and values, using the given seed.
|
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.
|
private static int |
hashMapField(java.lang.Object value)
Calculates the hash code of a map field.
|
boolean |
hasOneof(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
boolean |
isInitialized()
Returns true if all required fields in the message and all embedded
messages are set, false otherwise.
|
protected Message.Builder |
newBuilderForType(AbstractMessage.BuilderParent parent)
Create a nested builder.
|
(package private) UninitializedMessageException |
newUninitializedMessageException()
Package private helper method for AbstractParser to create
UninitializedMessageException with missing field information.
|
(package private) void |
setMemoizedSerializedSize(int size) |
private static ByteString |
toByteString(java.lang.Object value) |
java.lang.String |
toString()
Converts the message to a string in protocol buffer text format.
|
void |
writeTo(CodedOutputStream output)
Serializes the message and writes it to
output. |
addAll, addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeToclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetParserForType, newBuilderForType, toBuildertoByteArray, toByteString, writeDelimitedTo, writeTogetAllFields, getDefaultInstanceForType, getDescriptorForType, getField, getRepeatedField, getRepeatedFieldCount, getUnknownFields, hasFieldpublic boolean isInitialized()
MessageLiteOrBuilderisInitialized in interface MessageLiteOrBuilderprotected Message.Builder newBuilderForType(AbstractMessage.BuilderParent parent)
public java.util.List<java.lang.String> findInitializationErrors()
MessageOrBuilderMessageLiteOrBuilder.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.findInitializationErrors in interface MessageOrBuilderpublic java.lang.String getInitializationErrorString()
MessageOrBuilderMessageLiteOrBuilder.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.getInitializationErrorString in interface MessageOrBuilderpublic boolean hasOneof(Descriptors.OneofDescriptor oneof)
hasOneof in interface MessageOrBuilderpublic Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
getOneofFieldDescriptor in interface MessageOrBuilderpublic final java.lang.String toString()
MessageTextFormat.printToString(MessageOrBuilder).public void writeTo(CodedOutputStream output) throws java.io.IOException
MessageLiteoutput. This does not
flush or close the stream.writeTo in interface MessageLitejava.io.IOExceptionint getMemoizedSerializedSize()
getMemoizedSerializedSize in class AbstractMessageLitevoid setMemoizedSerializedSize(int size)
setMemoizedSerializedSize in class AbstractMessageLitepublic int getSerializedSize()
MessageLitegetSerializedSize in interface MessageLitepublic boolean equals(java.lang.Object other)
Messagetrue 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.public int hashCode()
MessageObject.hashCode() is incorrect.private static ByteString toByteString(java.lang.Object value)
private static boolean compareBytes(java.lang.Object a,
java.lang.Object b)
private static java.util.Map convertMapEntryListToMap(java.util.List list)
private static boolean compareMapField(java.lang.Object a,
java.lang.Object b)
static boolean compareFields(java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> a, java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> b)
equals(Object)
and AbstractMutableMessage#equals(Object). It takes special care
of bytes fields because immutable messages and mutable messages use
different Java type to represent a bytes field and this method should be
able to compare immutable messages, mutable messages and also an immutable
message to a mutable message.private static int hashMapField(java.lang.Object value)
value must be a list of
MapEntry messages.protected static int hashFields(int hash,
java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> map)
UninitializedMessageException newUninitializedMessageException()
newUninitializedMessageException in class AbstractMessageLite@Deprecated protected static int hashLong(long n)
@Deprecated protected static int hashBoolean(boolean b)
@Deprecated protected static int hashEnum(Internal.EnumLite e)
@Deprecated protected static int hashEnumList(java.util.List<? extends Internal.EnumLite> list)