Google Dexmaker 代码解析(四)-- MethodId<D, R>

来源:互联网 发布:单身狗公仔淘宝 编辑:程序博客网 时间:2024/05/29 14:32

MethodId<D, R>

/** * Identifies a method or constructor. * * @param <D> the type declaring this field * @param <R> the return type of this method */

用来定义一个方法或者构造方法。

类结构图

构造方法

对外隐藏构造方法,无法直接new一个实例。

核心方法

  • isConstructor方法
    /**     * Returns true if this method is a constructor for its declaring class.     */    public boolean isConstructor() {        return name.equals("<init>");    }

判断该方法是否是一个构造方法。

  • getDeclaringType方法
public TypeId<D> getDeclaringType() {        return declaringType;    }

获取该方法所属class的type。

  • getReturnType方法
public TypeId<R> getReturnType() {        return returnType;    }

获取该方法返回结果的type。

  • getParameters方法
public List<TypeId<?>> getParameters() {        return parameters.asList();    }

以List的形式返回该方法定义的参数type。

0 0
原创粉丝点击