writer.format("j_%s.unwrap(%s)", unwrappedType.getName(), unwrappedName); } else { ParamInfo classTypeParam = method.resolveClassTypeParam(type); if (classTypeParam != null) { writer.format("utils.get_jtype(__args[%s]).unwrap(%s)", classTypeParam.getIndex(), unwrappedName);
writer.format(", utils.enum_jtype(%s)", arg.getName()); } else if (argKind == OBJECT) { ParamInfo classTypeParam = method != null ? method.resolveClassTypeParam((TypeVariableInfo) arg) : null; if (classTypeParam != null) { writer.format(", utils.get_jtype(__args[%s])", classTypeParam.getIndex()); convParam(model, method, null, false, new ParamInfo(0, "result", null, type.getArg(0)))); } else if (returnType.isVariable() && (method != null && method.resolveClassTypeParam((TypeVariableInfo) returnType) != null)) { ParamInfo classTypeParam = method.resolveClassTypeParam((TypeVariableInfo) returnType); return String.format("utils.get_jtype(__args[%s]).wrap(%s)", classTypeParam.getIndex(), templ); } else {
@Test public void testValidClassTypeParams() throws Exception { ClassModel model = new GeneratorHelper().generateClass(MethodWithValidClassTypeParams.class); List<MethodInfo> methods = model.getMethods(); assertEquals(2, methods.size()); MethodInfo methodParam = methods.get(0); checkMethod(methodParam, "methodParam", 2, "void", MethodKind.OTHER); ParamInfo resolved = methodParam.resolveClassTypeParam((TypeVariableInfo) methodParam.getParam(0).getType()); assertSame(resolved, methodParam.getParam(1)); MethodInfo returnParam = methods.get(1); checkMethod(returnParam, "returnParam", 1, "T", MethodKind.OTHER); resolved = methodParam.resolveClassTypeParam((TypeVariableInfo) returnParam.getReturnType()); assertSame(resolved, methodParam.getParam(1)); }
assertTrue(((TypeVariableInfo)params1.get(0).getType()).isClassParam()); assertFalse(((TypeVariableInfo)params1.get(0).getType()).isMethodParam()); assertNull(methods.get(0).resolveClassTypeParam((TypeVariableInfo) params1.get(0).getType())); checkParam(params1.get(1), "handler", new TypeLiteral<Handler<T>>(){}); checkParam(params1.get(2), "asyncResultHandler", new TypeLiteral<Handler<AsyncResult<T>>>(){}); assertFalse(((TypeVariableInfo) params2.get(0).getType()).isClassParam()); assertTrue(((TypeVariableInfo) params2.get(0).getType()).isMethodParam()); assertNull(methods.get(1).resolveClassTypeParam((TypeVariableInfo) params2.get(0).getType())); checkParam(params2.get(1), "handler", new TypeLiteral<Handler<R>>(){}); checkParam(params2.get(2), "asyncResultHandler", new TypeLiteral<Handler<AsyncResult<R>>>(){});