https://mp.weixin.qq.com/s/vf0PfjbxQ3Ywjk6tk85SfA

 
GenericParameterizedBundle的实现。
 
 
1. 基本介绍
 
a. Bundle:继承自Bundle,自定义的数据类型;
a. 参数化:类型化的参数为T params;
b. 通用的:cloneType返回的this.type为子类的类型;
 
2. 实现
 
覆盖了一个cloneType()方法。该方法的实现如下:
.getClass
.getConstructors.head
.newInstance(params)
]
 
如果在这个过程中出现问题,则抛出异常:
 
3. 子类的实例
 
 
TLBundle继承自GenericParameterizedBundle:
 
 
这里调用cloneType时:
a. this是tlBundle;
b. getConstructors.head是primary constructor:
emptyBundleParams
。这个this.type是随着子类类型的变化而变化的。
 
4. 附录
 
 
 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案