Package com.google.protobuf
Class AbstractMessage
java.lang.Object
com.google.protobuf.AbstractMessageLite
com.google.protobuf.AbstractMessage
- All Implemented Interfaces:
Message,MessageLite,MessageLiteOrBuilder,MessageOrBuilder
- Direct Known Subclasses:
DynamicMessage,GeneratedMessage,GeneratedMessageV3,MapEntry
A partial implementation of the
Message interface which implements as many methods of
that interface as possible in terms of other methods.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA partial implementation of theMessage.Builderinterface which implements as many methods of that interface as possible in terms of other methods.protected static interfaceInterface for the parent of a Builder that allows the builder to communicate invalidations back to the parent for use when using nested builders.Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite
AbstractMessageLite.InternalOneOfEnum -
Field Summary
FieldsFields inherited from class com.google.protobuf.AbstractMessageLite
memoizedHashCode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleancompareBytes(Object a, Object b) Compares two bytes fields.(package private) static booleanCompares two sets of fields.private static booleancompareMapField(Object a, Object b) Compares two map fields.private static MapconvertMapEntryListToMap(List list) Converts a list of MapEntry messages into a Map used for equals() and hashCode().booleanCompares the specified object with this message for equality.Returns a list of field paths (e.g.Returns a comma-delimited list of required fields which are not set in this message object.(package private) intObtains the FieldDescriptor if the given oneof is set.intGet the number of bytes required to encode this message.protected static inthashBoolean(boolean b) Deprecated.from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code.inthashCode()Returns the hash code value for this message.protected static intDeprecated.from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code.protected static inthashEnumList(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 inthashFields(int hash, Map<Descriptors.FieldDescriptor, Object> map) Get a hash code for given fields and values, using the given seed.protected static inthashLong(long n) Deprecated.from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code.private static inthashMapField(Object value) Calculates the hash code of a map field.booleanReturns true if the given oneof is set.booleanReturns true if all required fields in the message and all embedded messages are set, false otherwise.protected Message.BuilderCreate a nested builder.(package private) UninitializedMessageExceptionPackage private helper method for AbstractParser to create UninitializedMessageException with missing field information.(package private) voidsetMemoizedSerializedSize(int size) private static ByteStringtoByteString(Object value) final StringtoString()Converts the message to a string in protocol buffer text format.voidwriteTo(CodedOutputStream output) Serializes the message and writes it tooutput.Methods inherited from class com.google.protobuf.AbstractMessageLite
addAll, addAll, checkByteStringIsUtf8, getSerializedSize, toByteArray, toByteString, writeDelimitedTo, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.protobuf.Message
getParserForType, newBuilderForType, toBuilderMethods inherited from interface com.google.protobuf.MessageLite
toByteArray, toByteString, writeDelimitedTo, writeToMethods inherited from interface com.google.protobuf.MessageOrBuilder
getAllFields, getDefaultInstanceForType, getDescriptorForType, getField, getRepeatedField, getRepeatedFieldCount, getUnknownFields, hasField
-
Field Details
-
memoizedSize
protected int memoizedSize
-
-
Constructor Details
-
AbstractMessage
public AbstractMessage()
-
-
Method Details
-
isInitialized
public boolean isInitialized()Description copied from interface:MessageLiteOrBuilderReturns true if all required fields in the message and all embedded messages are set, false otherwise.- Specified by:
isInitializedin interfaceMessageLiteOrBuilder
-
newBuilderForType
Create a nested builder. -
findInitializationErrors
Description copied from interface:MessageOrBuilderReturns a list of field paths (e.g. "foo.bar.baz") of required fields which are not set in this message. You should callMessageLiteOrBuilder.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.- Specified by:
findInitializationErrorsin interfaceMessageOrBuilder
-
getInitializationErrorString
Description copied from interface:MessageOrBuilderReturns a comma-delimited list of required fields which are not set in this message object. You should callMessageLiteOrBuilder.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.- Specified by:
getInitializationErrorStringin interfaceMessageOrBuilder
-
hasOneof
Description copied from interface:MessageOrBuilderReturns true if the given oneof is set.- Specified by:
hasOneofin interfaceMessageOrBuilder
-
getOneofFieldDescriptor
Description copied from interface:MessageOrBuilderObtains the FieldDescriptor if the given oneof is set. Returns null if no field is set.- Specified by:
getOneofFieldDescriptorin interfaceMessageOrBuilder
-
toString
Description copied from interface:MessageConverts the message to a string in protocol buffer text format. This is just a trivial wrapper aroundTextFormat.Printer.printToString(MessageOrBuilder). -
writeTo
Description copied from interface:MessageLiteSerializes the message and writes it tooutput. This does not flush or close the stream.- Specified by:
writeToin interfaceMessageLite- Throws:
IOException
-
getMemoizedSerializedSize
int getMemoizedSerializedSize()- Overrides:
getMemoizedSerializedSizein classAbstractMessageLite
-
setMemoizedSerializedSize
void setMemoizedSerializedSize(int size) - Overrides:
setMemoizedSerializedSizein classAbstractMessageLite
-
getSerializedSize
public int getSerializedSize()Description copied from interface:MessageLiteGet 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.- Specified by:
getSerializedSizein interfaceMessageLite
-
equals
Description copied from interface:MessageCompares the specified object with this message for equality. Returnstrueif the given object is a message of the same type (as defined bygetDescriptorForType()) and has identical values for all of its fields. Subclasses must implement this; inheritingObject.equals()is incorrect. -
hashCode
public int hashCode()Description copied from interface:MessageReturns 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; inheritingObject.hashCode()is incorrect. -
toByteString
-
compareBytes
Compares two bytes fields. The parameters must be either a byte array or a ByteString object. They can be of different type though. -
convertMapEntryListToMap
Converts a list of MapEntry messages into a Map used for equals() and hashCode(). -
compareMapField
Compares two map fields. The parameters must be a list of MapEntry messages. -
compareFields
static boolean compareFields(Map<Descriptors.FieldDescriptor, Object> a, Map<Descriptors.FieldDescriptor, Object> b) Compares two sets of fields. This method is used to implementequals(Object)andAbstractMutableMessage#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. -
hashMapField
Calculates the hash code of a map field.valuemust be a list of MapEntry messages. -
hashFields
Get a hash code for given fields and values, using the given seed. -
newUninitializedMessageException
UninitializedMessageException newUninitializedMessageException()Package private helper method for AbstractParser to create UninitializedMessageException with missing field information.- Overrides:
newUninitializedMessageExceptionin classAbstractMessageLite
-
hashLong
Deprecated.from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code. -
hashBoolean
Deprecated.from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code. -
hashEnum
Deprecated.from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code. -
hashEnumList
Deprecated.from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code.
-