- 所有已知实现类:
DynamicCodecRegistry
public interface DsonCodecRegistry
编解码器注册表
- 作者:
- wjybxx date 2023/4/3
-
方法概要
修饰符和类型方法说明getDecoder(cn.wjybxx.base.TypeInfo typeInfo) 查找解码器(decoder)。getEncoder(cn.wjybxx.base.TypeInfo typeInfo) 查找编码器(encoder)。
-
方法详细资料
-
getEncoder
查找编码器(encoder)。1.可以返回超类的codec,因为子类实例可以向上转型,但子类特殊数据将被丢弃。 2.不可返回子类的codec,因为超类实例不能向下转型。
PS:可参考集合和字典的Codec实现。
- 参数:
typeInfo- 类型信息,含泛型参数
-
getDecoder
查找解码器(decoder)。1.可以返回子类的Codec,如果子类和当前类数据兼容。 2.不可向上转型,因为超类Codec创建的实例不能安全向下转型。 3.如果可以,请尽量返回当前类对应的Codec,以避免错误。
PS:可参考集合和字典的Codec实现。
- 参数:
typeInfo- 类型信息,含泛型参数
-