本文共 643 字,大约阅读时间需要 2 分钟。
介绍GenericParameterizedBundle的实现。
a. Bundle:继承自Bundle,自定义的数据类型; b. 通用的:cloneType返回的this.type为子类的类型; 覆盖了一个cloneType()方法。该方法的实现如下: a. 获取当前对象的类:this.getClass b. 获取第一个构造方法:.getConstructors.head c. 调用这个构造方法,并把参数传入:.newInstance(params) d. 类型转换:.asInstanceOf[this.type]
TLBundle继承自GenericParameterizedBundle:
b. getConstructors.head是primary constructor:
c. newInstance(params)传入的params为:TLBundleParameters.emptyBundleParams d. 类型转换为this.type,this.type为tlBundle.type。这个this.type是随着子类类型的变化而变化的。 转载于:https://www.cnblogs.com/wjcdx/p/10933697.html