This commit is contained in:
Redkale
2020-02-09 11:34:04 +08:00
parent 19932820a9
commit 7d23dfa73d
10 changed files with 171 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
/**
*
* @author zhangjx
*/
public class OneBean {
public int id;
}

View File

@@ -0,0 +1,14 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
/**
*
* @author zhangjx
*/
public class OneRound {
}

View File

@@ -0,0 +1,22 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
import org.redkale.service.RetResult;
/**
*
* @author zhangjx
* @param <OR>
* @param <OB>
*/
public class OneService<OR extends OneRound, OB extends OneBean> {
public RetResult run(OR round, OB bean) {
return RetResult.success();
}
}

View File

@@ -0,0 +1,15 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
/**
*
* @author zhangjx
*/
public class ThreeBean extends TwoBean {
public String desc;
}

View File

@@ -0,0 +1,14 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
/**
*
* @author zhangjx
*/
public class ThreeRound extends TwoRound {
}

View File

@@ -0,0 +1,20 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
/**
*
* @author zhangjx
* @param <K>
* @param <ER>
* @param <EB>
*/
public class ThreeService<K extends CharSequence, ER extends ThreeRound, EB extends ThreeBean> extends OneService<ER, EB> {
public String key(K key) {
return "" + key;
}
}

View File

@@ -0,0 +1,15 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
/**
*
* @author zhangjx
*/
public class TwoBean extends OneBean {
public String name;
}

View File

@@ -0,0 +1,14 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
/**
*
* @author zhangjx
*/
public class TwoRound extends OneRound {
}

View File

@@ -0,0 +1,16 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
/**
*
* @author zhangjx
* @param <TR>
* @param <TB>
*/
public class TwoService<TR extends TwoRound, TB extends TwoBean> extends OneService<TR, TB> {
}

View File

@@ -0,0 +1,26 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.type;
import java.lang.reflect.Method;
import org.redkale.util.TypeToken;
/**
*
* @author zhangjx
*/
public class TypeTokenTest {
public static void main(String[] args) throws Throwable {
Class declaringClass = TwoService.class;
for (Method method : declaringClass.getMethods()) {
if (!"run".equals(method.getName())) continue;
System.out.println(TypeToken.getGenericType(method.getGenericParameterTypes()[0], declaringClass));
break;
}
}
}