Package com.google.protobuf
Class MicroEJMessageLite
- java.lang.Object
-
- com.google.protobuf.MicroEJMessageLite
-
public abstract class MicroEJMessageLite extends Object
Base class for MicroEJ-generated protobuf messages.Replaces
GeneratedMessageLitefor environments withoutjava.lang.reflect. Generated message classes extend this and provide inlinewriteTo,mergeFrom, andgetSerializedSizeimplementations — no schema engine or reflection needed.Supports proto2 extensions via
FieldSetandExtensionRegistryLite.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classMicroEJMessageLite.ExtensionWriterUsed by subclasses to serialize extensions.
-
Field Summary
Fields Modifier and Type Field Description protected com.google.protobuf.FieldSet<com.google.protobuf.GeneratedMessageLite.ExtensionDescriptor>extensionsExtension fields for extensible messages.protected intmemoizedSerializedSizeprotected UnknownFieldSetLiteunknownFields
-
Constructor Summary
Constructors Constructor Description MicroEJMessageLite()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <T> voidaddRepeatedExtension(GeneratedMessageLite.GeneratedExtension<?,List<T>> extension, T value)Add a repeated extension value.protected voidclearExtension(GeneratedMessageLite.GeneratedExtension<?,?> extension)Clear an extension.protected com.google.protobuf.FieldSet<com.google.protobuf.GeneratedMessageLite.ExtensionDescriptor>ensureExtensionsAreMutable()Ensure the extension FieldSet is mutable.protected booleanextensionsAreEmpty()Check if extensions are empty.protected booleanextensionsAreEqual(MicroEJMessageLite other)Compare extensions with another message.protected booleanextensionsAreInitialized()Check that every message-typed extension is initialized.protected intextensionsHashCode()Hash code of extensions.protected voidextensionsMakeImmutable()Make extensions and unknown fields immutable.protected intextensionsSerializedSize()Returns the serialized size of all extension fields.abstract MicroEJMessageLitegetDefaultInstanceForType()Returns a new default (empty) instance of this message type.<T> TgetExtension(GeneratedMessageLite.GeneratedExtension<?,List<T>> extension, int index)Get one element of a repeated extension.<T> TgetExtension(GeneratedMessageLite.GeneratedExtension<?,T> extension)Get the value of an extension.<T> intgetExtensionCount(GeneratedMessageLite.GeneratedExtension<?,List<T>> extension)Get the number of elements in a repeated extension.abstract intgetSerializedSize()Returns the number of bytes required to serialize this message.UnknownFieldSetLitegetUnknownFields()Returns the unknown fields stored during parsing.<T> booleanhasExtension(GeneratedMessageLite.GeneratedExtension<?,T> extension)Check if a singular extension is present.booleanisInitialized()Returns true if all required fields are set (always true for proto3).protected voidmergeExtensionFields(MicroEJMessageLite other)Merge extension fields from another message: a repeated extension appends, a message-typed extension merges, any other singular extension is replaced.protected static UnknownFieldSetLitemergeUnknownFields(UnknownFieldSetLite first, UnknownFieldSetLite second)Returns the unknown fields of both sets, in a new set when the second one holds any.protected MicroEJMessageLitemicroejMerge(MicroEJMessageLite other)Create a new message by merging this message with another of the same type.protected MicroEJMessageLitemicroejParseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)Parse a new instance of this message type from a stream, without the required-field check.protected booleanparseExtensionOrUnknownField(MicroEJMessageLite defaultInstance, CodedInputStream input, ExtensionRegistryLite extensionRegistry, int tag)Parse an extension, or an unknown field when the registry knows no extension for the tag.protected booleanparseUnknownField(int tag, CodedInputStream input)Parses an unknown field duringmergeFromand stores it for round-trip preservation.protected static MicroEJMessageLitereadMessage(MicroEJMessageLite defaultInstance, CodedInputStream input, ExtensionRegistryLite extensionRegistry)Reads a nested message of the given type, delimited by a length prefix.protected <T> voidsetExtension(GeneratedMessageLite.GeneratedExtension<?,T> extension, T value)Set a singular extension value.byte[]toByteArray()Serializes this message to a byte array.ByteStringtoByteString()Returns aByteStringcontaining the serialized message.protected voidunknownFieldsMakeImmutable()Make the unknown fields immutable.voidwriteDelimitedTo(OutputStream output)Serializes this message with a varint length prefix to anOutputStream.abstract voidwriteTo(CodedOutputStream output)Serializes this message to aCodedOutputStream.voidwriteTo(OutputStream output)Serializes this message to anOutputStream.
-
-
-
Field Detail
-
unknownFields
protected UnknownFieldSetLite unknownFields
-
memoizedSerializedSize
protected int memoizedSerializedSize
-
extensions
protected com.google.protobuf.FieldSet<com.google.protobuf.GeneratedMessageLite.ExtensionDescriptor> extensions
Extension fields for extensible messages.
-
-
Method Detail
-
writeTo
public abstract void writeTo(CodedOutputStream output) throws IOException
Serializes this message to aCodedOutputStream.- Throws:
IOException
-
getSerializedSize
public abstract int getSerializedSize()
Returns the number of bytes required to serialize this message.
-
getDefaultInstanceForType
public abstract MicroEJMessageLite getDefaultInstanceForType()
Returns a new default (empty) instance of this message type.
-
isInitialized
public boolean isInitialized()
Returns true if all required fields are set (always true for proto3).
-
toByteArray
public final byte[] toByteArray()
Serializes this message to a byte array.
-
writeTo
public final void writeTo(OutputStream output) throws IOException
Serializes this message to anOutputStream.- Throws:
IOException
-
writeDelimitedTo
public final void writeDelimitedTo(OutputStream output) throws IOException
Serializes this message with a varint length prefix to anOutputStream.- Throws:
IOException
-
toByteString
public final ByteString toByteString()
Returns aByteStringcontaining the serialized message.
-
parseUnknownField
protected final boolean parseUnknownField(int tag, CodedInputStream input) throws IOExceptionParses an unknown field duringmergeFromand stores it for round-trip preservation.- Parameters:
tag- the field tag that was not recognizedinput- the input stream positioned after the tag- Returns:
- false if the tag is an end-group marker, true otherwise
- Throws:
IOException
-
getUnknownFields
public final UnknownFieldSetLite getUnknownFields()
Returns the unknown fields stored during parsing.
-
mergeUnknownFields
protected static UnknownFieldSetLite mergeUnknownFields(UnknownFieldSetLite first, UnknownFieldSetLite second)
Returns the unknown fields of both sets, in a new set when the second one holds any. For use by generated code.
-
readMessage
protected static MicroEJMessageLite readMessage(MicroEJMessageLite defaultInstance, CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException
Reads a nested message of the given type, delimited by a length prefix. For use by generated code.- Throws:
IOException
-
ensureExtensionsAreMutable
protected com.google.protobuf.FieldSet<com.google.protobuf.GeneratedMessageLite.ExtensionDescriptor> ensureExtensionsAreMutable()
Ensure the extension FieldSet is mutable. For use by generated code.
-
mergeExtensionFields
protected void mergeExtensionFields(MicroEJMessageLite other)
Merge extension fields from another message: a repeated extension appends, a message-typed extension merges, any other singular extension is replaced. For use by generated builder code.
-
parseExtensionOrUnknownField
protected boolean parseExtensionOrUnknownField(MicroEJMessageLite defaultInstance, CodedInputStream input, ExtensionRegistryLite extensionRegistry, int tag) throws IOException
Parse an extension, or an unknown field when the registry knows no extension for the tag. For use by generated code only.- Parameters:
defaultInstance- the default instance of this message type (for registry lookup)input- the coded input streamextensionRegistry- the extension registrytag- the field tag already read- Returns:
trueunless the tag is an end-group tag- Throws:
IOException
-
hasExtension
public final <T> boolean hasExtension(GeneratedMessageLite.GeneratedExtension<?,T> extension)
Check if a singular extension is present.
-
getExtension
public final <T> T getExtension(GeneratedMessageLite.GeneratedExtension<?,T> extension)
Get the value of an extension.
-
getExtensionCount
public final <T> int getExtensionCount(GeneratedMessageLite.GeneratedExtension<?,List<T>> extension)
Get the number of elements in a repeated extension.
-
getExtension
public final <T> T getExtension(GeneratedMessageLite.GeneratedExtension<?,List<T>> extension, int index)
Get one element of a repeated extension.
-
setExtension
protected final <T> void setExtension(GeneratedMessageLite.GeneratedExtension<?,T> extension, T value)
Set a singular extension value. For use by generated Builder code.
-
addRepeatedExtension
protected final <T> void addRepeatedExtension(GeneratedMessageLite.GeneratedExtension<?,List<T>> extension, T value)
Add a repeated extension value. For use by generated Builder code.
-
clearExtension
protected final void clearExtension(GeneratedMessageLite.GeneratedExtension<?,?> extension)
Clear an extension. For use by generated Builder code.
-
extensionsAreEmpty
protected boolean extensionsAreEmpty()
Check if extensions are empty. For use by generated code.
-
extensionsAreEqual
protected boolean extensionsAreEqual(MicroEJMessageLite other)
Compare extensions with another message. For use by generated equals().
-
extensionsHashCode
protected int extensionsHashCode()
Hash code of extensions. For use by generated hashCode().
-
extensionsMakeImmutable
protected void extensionsMakeImmutable()
Make extensions and unknown fields immutable. For use by generated makeImmutable().
-
unknownFieldsMakeImmutable
protected void unknownFieldsMakeImmutable()
Make the unknown fields immutable. For use by generated makeImmutable().
-
extensionsAreInitialized
protected boolean extensionsAreInitialized()
Check that every message-typed extension is initialized. For use by generated isInitialized().
-
extensionsSerializedSize
protected int extensionsSerializedSize()
Returns the serialized size of all extension fields.
-
microejParseFrom
protected MicroEJMessageLite microejParseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException
Parse a new instance of this message type from a stream, without the required-field check. Generated code overrides this;MicroEJParserand the nested message parsing rely on it.- Throws:
IOException
-
microejMerge
protected MicroEJMessageLite microejMerge(MicroEJMessageLite other)
Create a new message by merging this message with another of the same type. Generated code overrides this for message-type extension support.
-
-