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

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

Rocket - util - GenericParameterizedBundle的更多相关文章

  1. Rocket - util - Annotations

    https://mp.weixin.qq.com/s/7C8ZmPpwAqFqyKjL9K40Fg   介绍util中定义的注解(Annotations).   ​​   1. Annotation ...

  2. Rocket - util - Timer

    https://mp.weixin.qq.com/s/Z4JJhZ_jL1lqF1nf_orq9A   简单介绍Timer的实现.   ​​   1. 基本功能   实现定时器的功能.   2. Ti ...

  3. Rocket - util - Replacement

    https://mp.weixin.qq.com/s/zCP7wPuxgQ-r94Tr6BV5iw   简单介绍Replacement的实现.   ​​   1. 基本介绍   用于实现Cache替换 ...

  4. Rocket - util - ReduceOthers

    https://mp.weixin.qq.com/s/gbR5fuDbE_nUFVxw-p4rsA   简单介绍ReduceOthers的实现.   ​​   1. 基本介绍   输入一组Bool元素 ...

  5. Rocket - util - Repeater

    https://mp.weixin.qq.com/s/xyEq3DgYuf2QuNjssv8pkA   简单介绍Repeater的实现.   ​​   1. 基本功能   A Repeater pas ...

  6. Rocket - util - PrefixSum

    https://mp.weixin.qq.com/s/G2vLP-ncoJzSOgxGGEJkfA   简单介绍PrefixSum的实现.   ​​   1. 基本介绍   ​​ 把一个序列从前向后逐 ...

  7. Rocket - util - MultiWidthFifo

    https://mp.weixin.qq.com/s/CUnrpyQN5LRBR5bxC5u86A   简单介绍MultiWidthFifo的实现.   ​​   1. 基本介绍   实现一个输入宽度 ...

  8. Rocket - util - MaskGen

    https://mp.weixin.qq.com/s/_aJqf1cFJDK5RVRBhxTWOw   介绍MaskGen的实现.   ​​   1. 基本介绍   给定总线宽度beatBytes,根 ...

  9. Rocket - util - Misc

    https://mp.weixin.qq.com/s/kf4FvAFye_bRdT49Yow7Hg   简单介绍Misc中各个辅助方法的用途和实现.   ​​   1. ParameterizedBu ...

随机推荐

  1. 001_python变量,if,while

    Python介绍 python的出生与应用 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆(中文名字:龟叔)为了在阿姆斯特丹打发时间, ...

  2. 带你100% 地了解 Redis 6.0 的客户端缓存

    近日 Redis 6.0.0 GA 版本发布,这是 Redis 历史上最大的一次版本更新,包括了客户端缓存 (Client side caching).ACL.Threaded I/O 和 Redis ...

  3. Android广播时间——实现强制下线功能

    目录 思路:强制下线功能需要先关闭掉所有的活动,然后回到登录界面. 步骤 1.关闭所有活动 2.创建BaseActivity类作为所有活动的父类,因为需要用ActivityCollector管理所有活 ...

  4. 蓝桥杯备战(一)3n+1问题

    [问题描述] 考虑如下的序列生成算法:从整数 n 开始,如果 n 是偶数,把它除以 2:如果 n 是奇数,把它乘 3 加1.用新得到的值重复上述步骤,直到 n = 1 时停止.例如,n = 22 时该 ...

  5. tp5 一次性插入大量数据时分批处理

    如题,加入$arr 中有一万多条数据,如果直接使用insert插入的话就会报错,此时可以使用limit分批插入 $result = Db::connect($this->dbconfig()) ...

  6. PAT 1009 Product of Polynomials (25分) 指数做数组下标,系数做值

    题目 This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: E ...

  7. hadoop与spark的处理技巧(一)Top N处理技巧

    1.MR的topN处理方案,假设所有输入Key都唯一 2.MR的topN处理方案,假设输入Key不唯一 3.spark的topN处理方案,假设所有输入Key都唯一,不使用top()和takeOrder ...

  8. spark机器学习从0到1特征抽取–CountVectorizer(十三)

        一.概念 CountVectorizer 旨在通过计数来将一个文档转换为向量.当不存在先验字典时,Countvectorizer作为Estimator提取词汇进行训练,并生成一个CountVe ...

  9. 如何在Unity中画抛物线

    using UnityEngine; using System.Collections; using System.Collections.Generic; [ExecuteInEditMode] p ...

  10. 2.5 Hello golang

    编写第一个hello golang 创建空文件hello.go,尝试执行 touch hello.go go run hello.go 产生如下报错 can't load package: packa ...