zoukankan      html  css  js  c++  java
  • Rocket

    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. 附录
     
     
     
  • 相关阅读:
    windown reids
    redis 类型、方法
    nginx 路由配置
    http status code
    beego orm mysql
    thinkphp5
    beego
    MAC 更新brew 镜像源
    php session存入redis
    ios项目开发— iOS8 定位功能API改变
  • 原文地址:https://www.cnblogs.com/wjcdx/p/10933697.html
Copyright © 2011-2022 走看看