unpack
Unpacks this Any message into a message of type T.
This method deserializes the content of this Any message and returns it as an instance of type T. Before unpacking, it verifies that the type URL matches the expected message type. If the type URL does not match, an IllegalArgumentException is thrown.
Example:
val any: Any = receiveFromNetwork()
if (any.contains<Timestamp>()) {
val timestamp = any.unpack<Timestamp>()
processTimestamp(timestamp)
}Return
the unpacked message of type T
Type Parameters
the protobuf message type to unpack to
See also
Throws
Unpacks this Any message into a message of class kClass.
This method deserializes the content of this Any message and returns it as an instance of class kClass. Before unpacking, it verifies that the type URL matches the expected message type. If the type URL does not match, an IllegalArgumentException is thrown.
Example:
val any: Any = receiveFromNetwork()
if (any.contains<Timestamp>()) {
val timestamp = any.unpack(Timestamp::class)
processTimestamp(timestamp)
}Return
the unpacked message of type T
Parameters
the protobuf message class to unpack to
See also
Throws
Unpacks this Any message into a message of type kType.
This method deserializes the content of this Any message and returns it as an instance of type kType. Before unpacking, it verifies that the type URL matches the expected message type. If the type URL does not match, an IllegalArgumentException is thrown.
Example:
val any: Any = receiveFromNetwork()
if (any.contains<Timestamp>()) {
val timestamp = any.unpack<Timestamp>(typeOf<Timestamp>())
processTimestamp(timestamp)
}Return
the unpacked message of type T
Parameters
the protobuf message type to unpack to