/** * Given a type variable resolve the Java class of that variable. * * @param c the concrete class from which all type variables are resolved. * @param dc the declaring class where the type variable was defined. * @param tv the type variable. * @return the resolved Java class and type, otherwise null if the type variable * could not be resolved. */ public static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv) { return resolveTypeVariable(c, dc, tv, new HashMap<TypeVariable, Type>()); }
/** * Given a type variable resolve the Java class of that variable. * * @param c the concrete class from which all type variables are resolved. * @param dc the declaring class where the type variable was defined. * @param tv the type variable. * @return the resolved Java class and type, otherwise null if the type variable * could not be resolved. */ public static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv) { return resolveTypeVariable(c, dc, tv, new HashMap<TypeVariable, Type>()); }
private static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv, final Map<TypeVariable, Type> map) { final Type[] gis = c.getGenericInterfaces(); for (final Type gi : gis) { if (gi instanceof ParameterizedType) { // process pt of interface final ParameterizedType pt = (ParameterizedType) gi; final ClassTypePair ctp = resolveTypeVariable(pt, (Class<?>) pt.getRawType(), dc, tv, map); if (ctp != null) { return ctp; } } } final Type gsc = c.getGenericSuperclass(); if (gsc instanceof ParameterizedType) { // process pt of class final ParameterizedType pt = (ParameterizedType) gsc; return resolveTypeVariable(pt, c.getSuperclass(), dc, tv, map); } else if (gsc instanceof Class) { return resolveTypeVariable(c.getSuperclass(), dc, tv, map); } return null; }
private static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv, final Map<TypeVariable, Type> map) { final Type[] gis = c.getGenericInterfaces(); for (final Type gi : gis) { if (gi instanceof ParameterizedType) { // process pt of interface final ParameterizedType pt = (ParameterizedType) gi; final ClassTypePair ctp = resolveTypeVariable(pt, (Class<?>) pt.getRawType(), dc, tv, map); if (ctp != null) { return ctp; } } } final Type gsc = c.getGenericSuperclass(); if (gsc instanceof ParameterizedType) { // process pt of class final ParameterizedType pt = (ParameterizedType) gsc; return resolveTypeVariable(pt, c.getSuperclass(), dc, tv, map); } else if (gsc instanceof Class) { return resolveTypeVariable(c.getSuperclass(), dc, tv, map); } return null; }
private Class getResolvedType(final Type t, final Class c, final Class dc) { if (t instanceof Class) { return (Class) t; } else if (t instanceof TypeVariable) { final ClassTypePair ct = ReflectionHelper.resolveTypeVariable(c, dc, (TypeVariable) t); if (ct != null) { return ct.rawClass(); } else { return null; } } else if (t instanceof ParameterizedType) { final ParameterizedType pt = (ParameterizedType) t; return (Class) pt.getRawType(); } else { return null; } } }
private Class getResolvedType(final Type t, final Class c, final Class dc) { if (t instanceof Class) { return (Class) t; } else if (t instanceof TypeVariable) { final ClassTypePair ct = ReflectionHelper.resolveTypeVariable(c, dc, (TypeVariable) t); if (ct != null) { return ct.rawClass(); } else { return null; } } else if (t instanceof ParameterizedType) { final ParameterizedType pt = (ParameterizedType) t; return (Class) pt.getRawType(); } else { return null; } } }
} else if (a instanceof TypeVariable) { final TypeVariable tv = (TypeVariable) a; final ClassTypePair ctp = resolveTypeVariable(p.concreteClass, p.declaringClass, tv); cas[i] = (ctp != null) ? ctp.rawClass() : (Class<?>) (tv.getBounds()[0]); } else if (a instanceof GenericArrayType) {
} else if (a instanceof TypeVariable) { final TypeVariable tv = (TypeVariable) a; final ClassTypePair ctp = resolveTypeVariable(p.concreteClass, p.declaringClass, tv); cas[i] = (ctp != null) ? ctp.rawClass() : (Class<?>) (tv.getBounds()[0]); } else if (a instanceof GenericArrayType) {
ras[i] = a; } else if (a instanceof TypeVariable) { final ClassTypePair ctp = resolveTypeVariable(p.concreteClass, p.declaringClass, (TypeVariable) a); if (ctp == null) { throw new IllegalArgumentException(
ras[i] = a; } else if (a instanceof TypeVariable) { final ClassTypePair ctp = resolveTypeVariable(p.concreteClass, p.declaringClass, (TypeVariable) a); if (ctp == null) { throw new IllegalArgumentException(
return resolveTypeVariable(c, dc, tv, subMap);
return resolveTypeVariable(c, dc, tv, subMap);
final Class rawResolvedType, final Type genericResolvedType) { if (genericResolvedType instanceof TypeVariable) { final ClassTypePair ct = resolveTypeVariable( concreteClass, declaringClass,
final Class rawResolvedType, final Type genericResolvedType) { if (genericResolvedType instanceof TypeVariable) { final ClassTypePair ct = resolveTypeVariable( concreteClass, declaringClass,
/** * Given a type variable resolve the Java class of that variable. * * @param c the concrete class from which all type variables are resolved. * @param dc the declaring class where the type variable was defined. * @param tv the type variable. * @return the resolved Java class and type, otherwise null if the type variable * could not be resolved. */ public static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv) { return resolveTypeVariable(c, dc, tv, new HashMap<TypeVariable, Type>()); }
/** * Given a type variable resolve the Java class of that variable. * * @param c the concrete class from which all type variables are resolved. * @param dc the declaring class where the type variable was defined. * @param tv the type variable. * @return the resolved Java class and type, otherwise null if the type variable * could not be resolved. */ public static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv) { return resolveTypeVariable(c, dc, tv, new HashMap<TypeVariable, Type>()); }
/** * Given a type variable resolve the Java class of that variable. * * @param c the concrete class from which all type variables are resolved. * @param dc the declaring class where the type variable was defined. * @param tv the type variable. * @return the resolved Java class and type, otherwise null if the type variable * could not be resolved. */ public static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv) { return resolveTypeVariable(c, dc, tv, new HashMap<TypeVariable, Type>()); }
/** * Given a type variable resolve the Java class of that variable. * * @param c the concrete class from which all type variables are resolved. * @param dc the declaring class where the type variable was defined. * @param tv the type variable. * @return the resolved Java class and type, otherwise null if the type variable * could not be resolved. */ public static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv) { return resolveTypeVariable(c, dc, tv, new HashMap<TypeVariable, Type>()); }
/** * Given a type variable resolve the Java class of that variable. * * @param c the concrete class from which all type variables are resolved. * @param dc the declaring class where the type variable was defined. * @param tv the type variable. * @return the resolved Java class and type, otherwise null if the type variable * could not be resolved. */ public static ClassTypePair resolveTypeVariable(final Class<?> c, final Class<?> dc, final TypeVariable tv) { return resolveTypeVariable(c, dc, tv, new HashMap<TypeVariable, Type>()); }
private Class getResolvedType(final Type t, final Class c, final Class dc) { if (t instanceof Class) { return (Class) t; } else if (t instanceof TypeVariable) { final ClassTypePair ct = ReflectionHelper.resolveTypeVariable(c, dc, (TypeVariable) t); if (ct != null) { return ct.rawClass(); } else { return null; } } else if (t instanceof ParameterizedType) { final ParameterizedType pt = (ParameterizedType) t; return (Class) pt.getRawType(); } else { return null; } } }