unpackIntoHelper<T extends GeneratedMessage> function Null safety

void unpackIntoHelper<T extends GeneratedMessage>(
  1. List<int> value,
  2. T instance,
  3. String typeUrl,
  4. {ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY}
)

Unpacks the message in value into instance.

Throws a InvalidProtocolBufferException if typeUrl does not correspond with the type of instance.

This is a helper method for Any.unpackInto.

Implementation

void unpackIntoHelper<T extends GeneratedMessage>(
    List<int> value, T instance, String typeUrl,
    {ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY}) {
  // From "google/protobuf/any.proto":
  //
  //   The pack methods provided by protobuf library will by default use
  //   'type.googleapis.com/full.type.name' as the type URL and the unpack
  //   methods only use the fully qualified type name after the last '/'
  //   in the type URL, for example "foo.bar.com/x/y.z" will yield type
  //   name "y.z".
  if (!canUnpackIntoHelper(instance, typeUrl)) {
    var typeName = instance.info_.qualifiedMessageName;
    throw InvalidProtocolBufferException.wrongAnyMessage(
        _typeNameFromUrl(typeUrl), typeName);
  }
  instance.mergeFromBuffer(value, extensionRegistry);
}