This commit is contained in:
@@ -73,6 +73,7 @@ public abstract class TypeToken<T> {
|
|||||||
* }
|
* }
|
||||||
* public abstract class AService <K extends Key, V extends Val> {
|
* public abstract class AService <K extends Key, V extends Val> {
|
||||||
* public abstract V findValue(K key);
|
* public abstract V findValue(K key);
|
||||||
|
* public abstract Sheet<V> queryValue(K key);
|
||||||
* }
|
* }
|
||||||
* public class Key2 extends Key {
|
* public class Key2 extends Key {
|
||||||
* }
|
* }
|
||||||
@@ -82,6 +83,9 @@ public abstract class TypeToken<T> {
|
|||||||
* public Val2 findValue(Key2 key){
|
* public Val2 findValue(Key2 key){
|
||||||
* return new Val2();
|
* return new Val2();
|
||||||
* }
|
* }
|
||||||
|
* public Sheet<Val2> queryValue(Key2 key){
|
||||||
|
* return new Sheet();
|
||||||
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
@@ -92,7 +96,7 @@ public abstract class TypeToken<T> {
|
|||||||
* @return Type
|
* @return Type
|
||||||
*/
|
*/
|
||||||
public static Type getGenericType(final Type type, final Type declaringClass) {
|
public static Type getGenericType(final Type type, final Type declaringClass) {
|
||||||
if (declaringClass == null) return type;
|
if (type == null || declaringClass == null) return type;
|
||||||
if (type instanceof TypeVariable) {
|
if (type instanceof TypeVariable) {
|
||||||
if (declaringClass instanceof Class) {
|
if (declaringClass instanceof Class) {
|
||||||
final Class declaringClass0 = (Class) declaringClass;
|
final Class declaringClass0 = (Class) declaringClass;
|
||||||
@@ -117,6 +121,12 @@ public abstract class TypeToken<T> {
|
|||||||
TypeVariable tv = (TypeVariable) type;
|
TypeVariable tv = (TypeVariable) type;
|
||||||
if (tv.getBounds().length == 1) return tv.getBounds()[0];
|
if (tv.getBounds().length == 1) return tv.getBounds()[0];
|
||||||
}
|
}
|
||||||
|
if (type instanceof ParameterizedType) {
|
||||||
|
ParameterizedType pt = (ParameterizedType) type;
|
||||||
|
return createParameterizedType(getGenericType(pt.getOwnerType(), declaringClass),
|
||||||
|
getGenericType(pt.getRawType(), declaringClass),
|
||||||
|
getGenericType(pt.getActualTypeArguments(), declaringClass));
|
||||||
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user