Package com.google.protobuf
Interface Schema<T>
-
- All Known Implementing Classes:
MessageSchema
,MessageSetSchema
@ExperimentalApi interface Schema<T>
A runtime schema for a single protobuf message. A schema provides operations on message instances such as serialization/deserialization.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
equals(T message, T other)
Determine of the two messages are equal.int
getSerializedSize(T message)
Compute the serialized size of the message.int
hashCode(T message)
Compute a hashCode for the message.boolean
isInitialized(T message)
Checks whether all required fields are set.void
makeImmutable(T message)
Marks repeated/map/extension/unknown fields as immutable.void
mergeFrom(T message, byte[] data, int position, int limit, ArrayDecoders.Registers registers)
Like the above but parses from a byte[] without extensions.void
mergeFrom(T message, Reader reader, ExtensionRegistryLite extensionRegistry)
Reads fields from the givenReader
and merges them into the message.void
mergeFrom(T message, T other)
Merge values fromother
intomessage
.T
newInstance()
Creates a new instance of the message class.void
writeTo(T message, Writer writer)
Writes the given message to the targetWriter
.
-
-
-
Method Detail
-
writeTo
void writeTo(T message, Writer writer) throws java.io.IOException
Writes the given message to the targetWriter
.- Throws:
java.io.IOException
-
mergeFrom
void mergeFrom(T message, Reader reader, ExtensionRegistryLite extensionRegistry) throws java.io.IOException
Reads fields from the givenReader
and merges them into the message. It doesn't make the message immutable after parsing is done. To make the message immutable, usemakeImmutable(T)
.- Throws:
java.io.IOException
-
mergeFrom
void mergeFrom(T message, byte[] data, int position, int limit, ArrayDecoders.Registers registers) throws java.io.IOException
Like the above but parses from a byte[] without extensions. Entry point of fast path. Note that this method may throw IndexOutOfBoundsException if the input data is not valid protobuf wire format. Protobuf public API methods should catch and convert that exception to InvalidProtocolBufferException.- Throws:
java.io.IOException
-
makeImmutable
void makeImmutable(T message)
Marks repeated/map/extension/unknown fields as immutable.
-
isInitialized
boolean isInitialized(T message)
Checks whether all required fields are set.
-
newInstance
T newInstance()
Creates a new instance of the message class.
-
hashCode
int hashCode(T message)
Compute a hashCode for the message.
-
mergeFrom
void mergeFrom(T message, T other)
Merge values fromother
intomessage
. This method doesn't make the message immutable. To make the message immutable after merging, usemakeImmutable(T)
.
-
getSerializedSize
int getSerializedSize(T message)
Compute the serialized size of the message.
-
-