parameterizedtypeimpl_getparameter和getattribute的区别

parameterizedtypeimpl_getparameter和getattribute的区别publicinterfaceParameterizedTypeextendsTypeSubParam.Javapackagecom.github.retrofit2;/***Createdby刘春龙on2017/5/5.*/publicclassSubParamextendsParam{classMyClass{}classMyInvoke{}publicst…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

public interface ParameterizedType  extends Type

SubParam.Javapackage com.github.retrofit2;

/**

* Created by 刘春龙 on 2017/5/5.

*/

public class SubParam extends Param{

class MyClass{}

class MyInvoke{}

public static void main(String[] args) {

SubParam subParam = new SubParam();

}

}

Param.javapackage com.github.retrofit2;

import java.lang.reflect.ParameterizedType;

import java.lang.reflect.Type;

/**

* Created by 刘春龙 on 2017/5/5.

*/

public class Param{

private ClassentityClass;

class A {}

class B extends A {}

protected Param() {

Class clazz = this.getClass();

String typeName = clazz.getTypeName();

System.out.println(“[clazz] = ” + clazz);//[clazz] = class com.github.retrofit2.SubParam

System.out.println(“[type name] = ” + typeName);//[type name] = com.github.retrofit2.SubParam

Type type = clazz.getGenericSuperclass();

System.out.println(“[type] = ” + type);//[type] = com.github.retrofit2.ParamType actualType = ((ParameterizedType)type).getActualTypeArguments()[0];

System.out.println(“[actualType 1] = ” + actualType);//[actualType 1] = class com.github.retrofit2.SubParam$MyClass

actualType = ((ParameterizedType)type).getActualTypeArguments()[1];

System.out.println(“[actualType 2] = ” + actualType);//[actualType 2] = class com.github.retrofit2.SubParam$MyInvoke

this.entityClass = (Class)actualType;

B t = new B();

type = t.getClass().getGenericSuperclass();

System.out.println(“A is B’s super class :” + ((ParameterizedType)type).getActualTypeArguments().length);

}

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/218952.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • arrays.sort排序_js数组排序方法sort

    arrays.sort排序_js数组排序方法sortArrays.sort默认是升序,如果我们需要降序排列数组?Arrays.sort(distances);——升序Arrays.sort(distances,Collections.reverseOrder());——降序再说说Collections集合类,用来排序集合的Collections.sort(list)——升序Collections.reverse(list…

    2022年8月12日
  • 线性代数 行列式

    线性代数分为六大块:行列式矩阵向量方程组特征值二次型行列式一、行列式的概念1、二、三阶行列式2、排列、逆序、逆序数3、n阶行列式概念二、行列式的性质三、按行(列)展开公式1、代数余子式2、展开公式四、克拉默法则…

    2022年4月6日
  • pcep协议什么意思_PCEP – magnate3 – 博客园[通俗易懂]

    pcep协议什么意思_PCEP – magnate3 – 博客园[通俗易懂]PCEP是什么PCEP的全称是PathComputationElementCommunicationProtocol,直译过来就是路径计算单元通信协议。简单概括就是一个通信协议,基于TCP的应用层协议,具体用来干什么,会在下面逐步介绍。PCEP的发展曲线PCEP最初是想将路由器上的CSPF功能抽取出来,实现一个集中算路的能力,最初的时候是不温不火的;后面随着SDN大热,PCEP由于具备下发…

    2022年9月7日
  • 发现 Google Buzz 与 Google Code 进行了集成[通俗易懂]

    发现 Google Buzz 与 Google Code 进行了集成[通俗易懂]提交B3logSolo(运行在GAE/J上的博客程序)代码后发现GoogleCode版本控制系统会将提交日志同步发布到GoogleBuzz中:但在Buzzconnectedsites里并没有看到与GoogleCode关联:现在一提交代码就Buzz,还是比较无奈的….本文是使用B3logSolo从简约设计の艺术进行同步发布的原文地址:…

    2022年10月16日
  • iframe 透明兼容,设置iframe透明背景的方法「建议收藏」

    iframe 透明兼容,设置iframe透明背景的方法「建议收藏」从IE5.5+就支持iframe框架的背景透明。通过使用allowtransparency和background-color来设置iframe框架的透明效果,代码如下:1<iframesr

    2022年7月1日
  • 软件原型设计工具

    软件原型设计工具

    2022年1月23日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号