Package com.google.protobuf
Class GeneratedMessageLite<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>>
java.lang.Object
com.google.protobuf.AbstractMessageLite<MessageType,BuilderType>
com.google.protobuf.GeneratedMessageLite<MessageType,BuilderType>
- All Implemented Interfaces:
MessageLite
,MessageLiteOrBuilder
- Direct Known Subclasses:
GeneratedMessageLite.ExtendableMessage
public abstract class GeneratedMessageLite<MessageType extends GeneratedMessageLite<MessageType,BuilderType>,BuilderType extends GeneratedMessageLite.Builder<MessageType,BuilderType>>
extends AbstractMessageLite<MessageType,BuilderType>
Lite version of
GeneratedMessage
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
GeneratedMessageLite.Builder<MessageType extends GeneratedMessageLite<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>> protected static class
AParser
implementation that delegates to the default instance.static class
GeneratedMessageLite.ExtendableBuilder<MessageType extends GeneratedMessageLite.ExtendableMessage<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.ExtendableBuilder<MessageType, BuilderType>> Lite equivalent ofGeneratedMessage.ExtendableBuilder
.static class
GeneratedMessageLite.ExtendableMessage<MessageType extends GeneratedMessageLite.ExtendableMessage<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.ExtendableBuilder<MessageType, BuilderType>> Lite equivalent ofGeneratedMessage.ExtendableMessage
.static interface
GeneratedMessageLite.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageLite.ExtendableMessage<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.ExtendableBuilder<MessageType, BuilderType>> Lite equivalent ofGeneratedMessage.ExtendableMessageOrBuilder
.(package private) static final class
static class
Lite equivalent toGeneratedMessage.GeneratedExtension
.static enum
Defines which method path to invoke in#dynamicMethod(MethodToInvoke, Object...)
.protected static final class
A serialized (serializable) form of the generated message.Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite
AbstractMessageLite.InternalOneOfEnum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Map
<Class<?>, GeneratedMessageLite<?, ?>> private static final int
private int
We use the high bit of memoizedSerializedSize as the explicit mutability flag.private static final int
(package private) static final int
(package private) static final int
protected UnknownFieldSetLite
For use by generated code only.Fields inherited from class com.google.protobuf.AbstractMessageLite
memoizedHashCode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Object
Constructs aMessageInfo
for this message type.private static <MessageType extends GeneratedMessageLite.ExtendableMessage<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.ExtendableBuilder<MessageType, BuilderType>, T>
GeneratedMessageLite.GeneratedExtension<MessageType, T> checkIsLite
(ExtensionLite<MessageType, T> extension) Checks that theExtension
is Lite and returns it as aGeneratedMessageLite.GeneratedExtension
.private static <T extends GeneratedMessageLite<T,
?>>
TcheckMessageInitialized
(T message) Helper method to check if message is initialized.(package private) void
(package private) void
(package private) int
private int
computeSerializedSize
(Schema<?> nullableSchema) protected final <MessageType extends GeneratedMessageLite<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>>
BuilderTypeprotected final <MessageType extends GeneratedMessageLite<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>>
BuilderTypecreateBuilder
(MessageType prototype) protected abstract Object
dynamicMethod
(GeneratedMessageLite.MethodToInvoke method, Object arg0, Object arg1) A method that implements different types of operations described inGeneratedMessageLite.MethodToInvoke
.protected static Internal.BooleanList
protected static Internal.DoubleList
protected static Internal.FloatList
protected static Internal.IntList
protected static Internal.LongList
protected static <E> Internal.ProtobufList
<E> private void
Lazily initializes unknown fields.boolean
(package private) static <T extends GeneratedMessageLite<?,
?>>
TgetDefaultInstance
(Class<T> clazz) final MessageType
Get an instance of the type with no fields set.(package private) int
(package private) int
(package private) static Method
getMethodOrDie
(Class clazz, String name, Class... params) Calls Class.getMethod and throws a RuntimeException if it fails.final Parser
<MessageType> Gets the parser for a message of the same type as this message.int
Get the number of bytes required to encode this message.(package private) int
getSerializedSize
(Schema schema) int
hashCode()
(package private) boolean
(package private) static Object
invokeOrDie
(Method method, Object object, Object... params) Calls invoke and throws a RuntimeException if it fails.final boolean
Returns true if all required fields in the message and all embedded messages are set, false otherwise.private static final <T extends GeneratedMessageLite<T,
?>>
booleanisInitialized
(T message, boolean shouldMemoize) A static helper method for checking if a message is initialized, optionally memoizing.(package private) boolean
protected void
Called by subclasses to complete parsing.(package private) void
protected void
mergeLengthDelimitedField
(int fieldNumber, ByteString value) Called by subclasses to parse an unknown field.protected final void
mergeUnknownFields
(UnknownFieldSetLite unknownFields) Merge some unknown fields into theUnknownFieldSetLite
for this message.protected void
mergeVarintField
(int tag, int value) Called by subclasses to parse an unknown field.protected static Internal.BooleanList
protected static Internal.DoubleList
protected static Internal.FloatList
protected static Internal.IntList
mutableCopy
(Internal.IntList list) protected static Internal.LongList
mutableCopy
(Internal.LongList list) protected static <E> Internal.ProtobufList
<E> mutableCopy
(Internal.ProtobufList<E> list) final BuilderType
Constructs a new builder for a message of the same type as this message.protected static Object
newMessageInfo
(MessageLite defaultInstance, String info, Object[] objects) (package private) MessageType
static <ContainingType extends MessageLite,
Type>
GeneratedMessageLite.GeneratedExtension<ContainingType, Type> newRepeatedGeneratedExtension
(ContainingType containingTypeDefaultInstance, MessageLite messageDefaultInstance, Internal.EnumLiteMap<?> enumTypeMap, int number, WireFormat.FieldType type, boolean isPacked, Class singularType) For use by generated code only.static <ContainingType extends MessageLite,
Type>
GeneratedMessageLite.GeneratedExtension<ContainingType, Type> newSingularGeneratedExtension
(ContainingType containingTypeDefaultInstance, Type defaultValue, MessageLite messageDefaultInstance, Internal.EnumLiteMap<?> enumTypeMap, int number, WireFormat.FieldType type, Class singularType) For use by generated code only.protected static <T extends GeneratedMessageLite<T,
?>>
TparseDelimitedFrom
(T defaultInstance, InputStream input) protected static <T extends GeneratedMessageLite<T,
?>>
TparseDelimitedFrom
(T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, byte[] data) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, byte[] data, ExtensionRegistryLite extensionRegistry) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, ByteString data) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, CodedInputStream input) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, CodedInputStream input, ExtensionRegistryLite extensionRegistry) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, InputStream input) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, ByteBuffer data) protected static <T extends GeneratedMessageLite<T,
?>>
TparseFrom
(T defaultInstance, ByteBuffer data, ExtensionRegistryLite extensionRegistry) private static <T extends GeneratedMessageLite<T,
?>>
TparsePartialDelimitedFrom
(T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry) private static <T extends GeneratedMessageLite<T,
?>>
TparsePartialFrom
(T defaultInstance, byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry) A static helper method for parsing a partial from byte array.private static <T extends GeneratedMessageLite<T,
?>>
TparsePartialFrom
(T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry) protected static <T extends GeneratedMessageLite<T,
?>>
TparsePartialFrom
(T defaultInstance, CodedInputStream input) (package private) static <T extends GeneratedMessageLite<T,
?>>
TparsePartialFrom
(T instance, CodedInputStream input, ExtensionRegistryLite extensionRegistry) A static helper method for parsing a partial from input using the extension registry and the instance.protected boolean
parseUnknownField
(int tag, CodedInputStream input) Called by subclasses to parse an unknown field.protected static <T extends GeneratedMessageLite<?,
?>>
voidregisterDefaultInstance
(Class<T> clazz, T defaultInstance) (package private) void
setMemoizedHashCode
(int value) (package private) void
setMemoizedSerializedSize
(int size) final BuilderType
Constructs a builder initialized with the current message.toString()
A reflective toString function.void
writeTo
(CodedOutputStream output) Serializes the message and writes it tooutput
.Methods inherited from class com.google.protobuf.AbstractMessageLite
addAll, checkByteStringIsUtf8, newUninitializedMessageException, toByteArray, toByteString, writeDelimitedTo, writeTo
-
Field Details
-
UNINITIALIZED_SERIALIZED_SIZE
static final int UNINITIALIZED_SERIALIZED_SIZE- See Also:
-
MUTABLE_FLAG_MASK
private static final int MUTABLE_FLAG_MASK- See Also:
-
MEMOIZED_SERIALIZED_SIZE_MASK
private static final int MEMOIZED_SERIALIZED_SIZE_MASK- See Also:
-
memoizedSerializedSize
private int memoizedSerializedSizeWe use the high bit of memoizedSerializedSize as the explicit mutability flag. It didn't make sense to have negative sizes anyway. Messages start as mutable.Adding a standalone boolean would have added 8 bytes to every message instance.
We also reserve 0x7FFFFFFF as the "uninitialized" value.
-
UNINITIALIZED_HASH_CODE
static final int UNINITIALIZED_HASH_CODE- See Also:
-
unknownFields
For use by generated code only. Lazily initialized to reduce allocations. -
defaultInstanceMap
-
-
Constructor Details
-
GeneratedMessageLite
public GeneratedMessageLite()
-
-
Method Details
-
isMutable
boolean isMutable() -
markImmutable
void markImmutable() -
getMemoizedHashCode
int getMemoizedHashCode() -
setMemoizedHashCode
void setMemoizedHashCode(int value) -
clearMemoizedHashCode
void clearMemoizedHashCode() -
hashCodeIsNotMemoized
boolean hashCodeIsNotMemoized() -
getParserForType
Description copied from interface:MessageLite
Gets the parser for a message of the same type as this message. -
getDefaultInstanceForType
Description copied from interface:MessageLiteOrBuilder
Get an instance of the type with no fields set. Because no fields are set, all getters for singular fields will return default values and repeated fields will appear empty. This may or may not be a singleton. This differs from thegetDefaultInstance()
method of generated message classes in that this method is an abstract method of theMessageLite
interface whereasgetDefaultInstance()
is a static method of a specific class. They return the same thing. -
newBuilderForType
Description copied from interface:MessageLite
Constructs a new builder for a message of the same type as this message. -
newMutableInstance
MessageType newMutableInstance() -
toString
A reflective toString function. This is primarily intended as a developer aid, while keeping binary size down. The first line of thetoString()
representation includes a commented version ofsuper.toString()
to act as an indicator that this should not be relied on for comparisons.NOTE: This method relies on the field getter methods not being stripped or renamed by proguard. If they are, the fields will not be included in the returned string representation.
NOTE: This implementation is liable to change in the future, and should not be relied on in code.
-
hashCode
public int hashCode() -
computeHashCode
int computeHashCode() -
equals
-
ensureUnknownFieldsInitialized
private void ensureUnknownFieldsInitialized()Lazily initializes unknown fields. -
parseUnknownField
Called by subclasses to parse an unknown field. For use by generated code only.- Returns:
true
unless the tag is an end-group tag.- Throws:
IOException
-
mergeVarintField
protected void mergeVarintField(int tag, int value) Called by subclasses to parse an unknown field. For use by generated code only. -
mergeLengthDelimitedField
Called by subclasses to parse an unknown field. For use by generated code only. -
makeImmutable
protected void makeImmutable()Called by subclasses to complete parsing. For use by generated code only. -
createBuilder
protected final <MessageType extends GeneratedMessageLite<MessageType,BuilderType>, BuilderType createBuilder()BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>> -
createBuilder
protected final <MessageType extends GeneratedMessageLite<MessageType,BuilderType>, BuilderType createBuilderBuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>> (MessageType prototype) -
isInitialized
public final boolean isInitialized()Description copied from interface:MessageLiteOrBuilder
Returns true if all required fields in the message and all embedded messages are set, false otherwise. -
toBuilder
Description copied from interface:MessageLite
Constructs a builder initialized with the current message. Use this to derive a new message from the current one. -
dynamicMethod
protected abstract Object dynamicMethod(GeneratedMessageLite.MethodToInvoke method, Object arg0, Object arg1) A method that implements different types of operations described inGeneratedMessageLite.MethodToInvoke
. These different kinds of operations are required to implement message-level operations for builders in the runtime. This method bundles those operations to reduce the generated methods count.NEW_INSTANCE
returns a new instance of the protocol buffer that has not yet been made immutable. SeeMAKE_IMMUTABLE
.IS_INITIALIZED
returnsnull
for false and the default instance for true. It doesn't use or modify any memoized value.GET_MEMOIZED_IS_INITIALIZED
returns the memoizedisInitialized
byte value.SET_MEMOIZED_IS_INITIALIZED
sets the memoizedisInitialized
byte value to 1 if the first parameter is not null, or to 0 if the first parameter is null.NEW_BUILDER
returns aBuilderType
instance.
For use by generated code only.
-
clearMemoizedSerializedSize
void clearMemoizedSerializedSize() -
getMemoizedSerializedSize
int getMemoizedSerializedSize()- Overrides:
getMemoizedSerializedSize
in classAbstractMessageLite<MessageType extends GeneratedMessageLite<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>>
-
setMemoizedSerializedSize
void setMemoizedSerializedSize(int size) - Overrides:
setMemoizedSerializedSize
in classAbstractMessageLite<MessageType extends GeneratedMessageLite<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>>
-
writeTo
Description copied from interface:MessageLite
Serializes the message and writes it tooutput
. This does not flush or close the stream.- Throws:
IOException
-
getSerializedSize
- Overrides:
getSerializedSize
in classAbstractMessageLite<MessageType extends GeneratedMessageLite<MessageType,
BuilderType>, BuilderType extends GeneratedMessageLite.Builder<MessageType, BuilderType>>
-
getSerializedSize
public int getSerializedSize()Description copied from interface:MessageLite
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. -
computeSerializedSize
-
buildMessageInfo
Constructs aMessageInfo
for this message type.- Throws:
Exception
-
getDefaultInstance
-
registerDefaultInstance
protected static <T extends GeneratedMessageLite<?,?>> void registerDefaultInstance(Class<T> clazz, T defaultInstance) -
newMessageInfo
-
mergeUnknownFields
Merge some unknown fields into theUnknownFieldSetLite
for this message.For use by generated code only.
-
newSingularGeneratedExtension
public static <ContainingType extends MessageLite,Type> GeneratedMessageLite.GeneratedExtension<ContainingType,Type> newSingularGeneratedExtension(ContainingType containingTypeDefaultInstance, Type defaultValue, MessageLite messageDefaultInstance, Internal.EnumLiteMap<?> enumTypeMap, int number, WireFormat.FieldType type, Class singularType) For use by generated code only. -
newRepeatedGeneratedExtension
public static <ContainingType extends MessageLite,Type> GeneratedMessageLite.GeneratedExtension<ContainingType,Type> newRepeatedGeneratedExtension(ContainingType containingTypeDefaultInstance, MessageLite messageDefaultInstance, Internal.EnumLiteMap<?> enumTypeMap, int number, WireFormat.FieldType type, boolean isPacked, Class singularType) For use by generated code only. -
getMethodOrDie
Calls Class.getMethod and throws a RuntimeException if it fails. -
invokeOrDie
Calls invoke and throws a RuntimeException if it fails. -
checkIsLite
private static <MessageType extends GeneratedMessageLite.ExtendableMessage<MessageType,BuilderType>, GeneratedMessageLite.GeneratedExtension<MessageType,BuilderType extends GeneratedMessageLite.ExtendableBuilder<MessageType, BuilderType>, T> T> checkIsLite(ExtensionLite<MessageType, T> extension) Checks that theExtension
is Lite and returns it as aGeneratedMessageLite.GeneratedExtension
. -
isInitialized
private static final <T extends GeneratedMessageLite<T,?>> boolean isInitialized(T message, boolean shouldMemoize) A static helper method for checking if a message is initialized, optionally memoizing. -
emptyIntList
-
mutableCopy
-
emptyLongList
-
mutableCopy
-
emptyFloatList
-
mutableCopy
-
emptyDoubleList
-
mutableCopy
-
emptyBooleanList
-
mutableCopy
-
emptyProtobufList
-
mutableCopy
-
parsePartialFrom
static <T extends GeneratedMessageLite<T,?>> T parsePartialFrom(T instance, CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException A static helper method for parsing a partial from input using the extension registry and the instance.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
private static <T extends GeneratedMessageLite<T,?>> T parsePartialFrom(T defaultInstance, byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException A static helper method for parsing a partial from byte array.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
protected static <T extends GeneratedMessageLite<T,?>> T parsePartialFrom(T defaultInstance, CodedInputStream input) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
checkMessageInitialized
private static <T extends GeneratedMessageLite<T,?>> T checkMessageInitialized(T message) throws InvalidProtocolBufferException Helper method to check if message is initialized.- Returns:
- The message to check.
- Throws:
InvalidProtocolBufferException
- if it is not initialized.
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, ByteBuffer data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, ByteBuffer data) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, ByteString data) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parsePartialFrom
private static <T extends GeneratedMessageLite<T,?>> T parsePartialFrom(T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, byte[] data) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, InputStream input) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, CodedInputStream input) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseFrom(T defaultInstance, CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseDelimitedFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseDelimitedFrom(T defaultInstance, InputStream input) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parseDelimitedFrom
protected static <T extends GeneratedMessageLite<T,?>> T parseDelimitedFrom(T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-
parsePartialDelimitedFrom
private static <T extends GeneratedMessageLite<T,?>> T parsePartialDelimitedFrom(T defaultInstance, InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException - Throws:
InvalidProtocolBufferException
-