private void recordParametricReturnedType(Type parametricReturnType) { //push return type parameters onto parser context, only if this is a parametric type if (parametricReturnType instanceof ParameterizedType) { pCtx.setLastTypeParameters(((ParameterizedType) parametricReturnType).getActualTypeArguments()); ParameterizedType pt = (ParameterizedType) parametricReturnType; Type[] gpt = pt.getActualTypeArguments(); Type[] classArgs = type2Class(pt.getRawType()).getTypeParameters(); if (gpt.length > 0 && paramTypes == null) paramTypes = new HashMap<String, Type>(); for (int i = 0; i < gpt.length; i++) { paramTypes.put(classArgs[i].toString(), gpt[i]); } } }
private void recordParametricReturnedType(Type parametricReturnType) { //push return type parameters onto parser context, only if this is a parametric type if (parametricReturnType instanceof ParameterizedType) { pCtx.setLastTypeParameters(((ParameterizedType) parametricReturnType).getActualTypeArguments()); ParameterizedType pt = (ParameterizedType) parametricReturnType; Type[] gpt = pt.getActualTypeArguments(); Type[] classArgs = type2Class(pt.getRawType()).getTypeParameters(); if (gpt.length > 0 && paramTypes == null) paramTypes = new HashMap<String, Type>(); for (int i = 0; i < gpt.length; i++) { paramTypes.put(classArgs[i].toString(), gpt[i]); } } }
private Class<?> returnGenericType(Method m) { Type parametricReturnType = m.getGenericReturnType(); recordParametricReturnedType(parametricReturnType); String returnTypeArg = parametricReturnType.toString(); //push return type parameters onto parser context, only if this is a parametric type if (parametricReturnType instanceof ParameterizedType) { pCtx.setLastTypeParameters(((ParameterizedType) parametricReturnType).getActualTypeArguments()); } if (paramTypes != null && paramTypes.containsKey(returnTypeArg)) { /** * If the paramTypes Map contains the known type, return that type. */ return type2Class( paramTypes.get(returnTypeArg) ); } return m.getReturnType(); }
private Class<?> returnGenericType(Method m) { Type parametricReturnType = m.getGenericReturnType(); recordParametricReturnedType(parametricReturnType); String returnTypeArg = parametricReturnType.toString(); //push return type parameters onto parser context, only if this is a parametric type if (parametricReturnType instanceof ParameterizedType) { pCtx.setLastTypeParameters(((ParameterizedType) parametricReturnType).getActualTypeArguments()); } if (paramTypes != null && paramTypes.containsKey(returnTypeArg)) { /** * If the paramTypes Map contains the known type, return that type. */ return type2Class( paramTypes.get(returnTypeArg) ); } return m.getReturnType(); }
for (int i = 0; i < typeVariables.length; i++) { Type typeArg = pCtx.getLastTypeParameters()[i]; typeArgs.put(typeVariables[i].getName(), typeArg instanceof Class ? type2Class( pCtx.getLastTypeParameters()[i] ) : Object.class); return type2Class(paramTypes.get(returnTypeArg));
for (int i = 0; i < typeVariables.length; i++) { Type typeArg = pCtx.getLastTypeParameters()[i]; typeArgs.put(typeVariables[i].getName(), typeArg instanceof Class ? type2Class( pCtx.getLastTypeParameters()[i] ) : Object.class); return type2Class(paramTypes.get(returnTypeArg));
Type[] classArgs = type2Class(pt.getRawType()).getTypeParameters();
Type[] classArgs = type2Class(pt.getRawType()).getTypeParameters();
ctx = type2Class(pCtx.getLastTypeParameters() != null && pCtx.getLastTypeParameters().length != 0 ? pCtx.getLastTypeParameters()[1] : Object.class); ctx = pCtx.getLastTypeParameters() == null || pCtx.getLastTypeParameters().length == 0 ? Object.class : type2Class(pCtx.getLastTypeParameters()[0]);
ctx = type2Class(pCtx.getLastTypeParameters() != null && pCtx.getLastTypeParameters().length != 0 ? pCtx.getLastTypeParameters()[1] : Object.class); ctx = pCtx.getLastTypeParameters() == null || pCtx.getLastTypeParameters().length == 0 ? Object.class : type2Class(pCtx.getLastTypeParameters()[0]);