Add support for ExtensionRegistryLite in ProtobufDecoder

Motivation:

ExtensionRegistry is a subclass of ExtensionRegistryLite.  The ProtobufDecoder
doesn't use the registry directly, it simply passes it through to the Protobuf
API.  The Protobuf calls in question are themselves written in terms
ExtensionRegistryLite not ExtensionRegistry.

Modifications:

Require ExtensionRegistryLite instead of ExtensionRegistry in ProtobufDecoder.

Result:

Consumers can use ExtensionRegistryLite with ProtobufDecoder.
This commit is contained in:
Barber, Francis 2014-08-28 21:24:38 -07:00 committed by Norman Maurer
parent f7616d22eb
commit 08cec3c56b

View File

@ -16,6 +16,7 @@
package io.netty.handler.codec.protobuf;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.ExtensionRegistryLite;
import com.google.protobuf.Message;
import com.google.protobuf.MessageLite;
import io.netty.buffer.ByteBuf;
@ -78,7 +79,7 @@ public class ProtobufDecoder extends MessageToMessageDecoder<ByteBuf> {
}
private final MessageLite prototype;
private final ExtensionRegistry extensionRegistry;
private final ExtensionRegistryLite extensionRegistry;
/**
* Creates a new instance.
@ -88,6 +89,10 @@ public class ProtobufDecoder extends MessageToMessageDecoder<ByteBuf> {
}
public ProtobufDecoder(MessageLite prototype, ExtensionRegistry extensionRegistry) {
this(prototype, (ExtensionRegistryLite) extensionRegistry);
}
public ProtobufDecoder(MessageLite prototype, ExtensionRegistryLite extensionRegistry) {
if (prototype == null) {
throw new NullPointerException("prototype");
}