io.vertx.codegen.type.ParameterizedTypeInfo Java Examples
The following examples show how to use
io.vertx.codegen.type.ParameterizedTypeInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RxJavaGenerator.java From vertx-rx with Apache License 2.0 | 6 votes |
private MethodInfo genFutureMethod(MethodInfo method) { String futMethodName = genFutureMethodName(method); List<ParamInfo> futParams = new ArrayList<>(); int count = 0; int size = method.getParams().size() - 1; while (count < size) { ParamInfo param = method.getParam(count); /* Transform ReadStream -> Observable */ futParams.add(param); count = count + 1; } ParamInfo futParam = method.getParam(size); TypeInfo futType = ((ParameterizedTypeInfo) ((ParameterizedTypeInfo) futParam.getType()).getArg(0)).getArg(0); ParameterizedTypeInfo futReturnType = new io.vertx.codegen.type.ParameterizedTypeInfo(io.vertx.codegen.type.TypeReflectionFactory.create(rx.Single.class).getRaw(), false, java.util.Collections.singletonList(futType)); return method.copy().setName(futMethodName).setParams(futParams).setReturnType(futReturnType); }
Example #2
Source File: RxJava2Generator.java From vertx-rx with Apache License 2.0 | 6 votes |
private MethodInfo genFutureMethod(MethodInfo method) { String futMethodName = genFutureMethodName(method); List<ParamInfo> futParams = new ArrayList<>(); int count = 0; int size = method.getParams().size() - 1; while (count < size) { ParamInfo param = method.getParam(count); /* Transform ReadStream -> Flowable */ futParams.add(param); count = count + 1; } ParamInfo futParam = method.getParam(size); TypeInfo futType = ((ParameterizedTypeInfo) ((ParameterizedTypeInfo) futParam.getType()).getArg(0)).getArg(0); TypeInfo futUnresolvedType = ((ParameterizedTypeInfo) ((ParameterizedTypeInfo) futParam.getUnresolvedType()).getArg(0)).getArg(0); TypeInfo futReturnType; if (futUnresolvedType.getKind() == VOID) { futReturnType = io.vertx.codegen.type.TypeReflectionFactory.create(io.reactivex.Completable.class); } else if (futUnresolvedType.isNullable()) { futReturnType = new io.vertx.codegen.type.ParameterizedTypeInfo(io.vertx.codegen.type.TypeReflectionFactory.create(io.reactivex.Maybe.class).getRaw(), false, Collections.singletonList(futType)); } else { futReturnType = new io.vertx.codegen.type.ParameterizedTypeInfo(io.vertx.codegen.type.TypeReflectionFactory.create(io.reactivex.Single.class).getRaw(), false, Collections.singletonList(futType)); } return method.copy().setName(futMethodName).setReturnType(futReturnType).setParams(futParams); }
Example #3
Source File: ParamInfo.java From vertx-codegen with Apache License 2.0 | 6 votes |
/** * @return true when the param callback value is nullable: when the parameter type is an * handler or an async result handler it returns the nullable boolean of the corresponding * parameter, otherwise it returns null */ public Boolean isNullableCallback() { switch (type.getKind()) { case HANDLER: TypeInfo handler = ((ParameterizedTypeInfo)type).getArg(0); switch (handler.getKind()) { case ASYNC_RESULT: TypeInfo asyncResult = ((ParameterizedTypeInfo)handler).getArg(0); return asyncResult.isNullable(); default: return handler.isNullable(); } default: return null; } }
Example #4
Source File: ProxyTest.java From vertx-service-proxy with Apache License 2.0 | 5 votes |
@Test public void testValidCloseWithFuture() throws Exception { ProxyModel model = generateProxyModel(ValidProxyCloseWithFuture.class); assertEquals(1, model.getMethods().size()); assertEquals(MethodKind.FUTURE, model.getMethods().get(0).getKind()); ParameterizedTypeInfo handlerType = (ParameterizedTypeInfo) model.getMethods().get(0).getParams().get(0).getType(); ParameterizedTypeInfo asyncResultType = (ParameterizedTypeInfo) handlerType.getArgs().get(0); assertEquals(ClassKind.VOID, asyncResultType.getArgs().get(0).getKind()); }
Example #5
Source File: RxJavaGenerator.java From vertx-rx with Apache License 2.0 | 5 votes |
private static TypeInfo unwrap(TypeInfo type) { if (type instanceof ParameterizedTypeInfo) { return type.getRaw(); } else { return type; } }
Example #6
Source File: ClassNullableTest.java From vertx-codegen with Apache License 2.0 | 5 votes |
@Test public void testMethodWithHandlerNullable() throws Exception { for (Class<?> clazz : Arrays.asList( MethodWithHandlerNullable.class, MethodWithNullableTypeVariableHandler.class, MethodWithHandlerNullableVoid.class)) { generateClass(model -> { List<MethodInfo> methods = model.getMethods(); assertEquals(1, methods.size()); MethodInfo mi1 = methods.get(0); assertTrue(((ParameterizedTypeInfo) mi1.getParams().get(0).getType()).getArg(0).isNullable()); }, clazz); } }
Example #7
Source File: ClassNullableTest.java From vertx-codegen with Apache License 2.0 | 5 votes |
@Test public void testMethodWithNullableInheritedParams() throws Exception { Consumer<ClassModel> check = model -> { List<MethodInfo> methods = model.getMethods(); assertEquals(1, methods.size()); MethodInfo mi2 = methods.get(0); assertTrue(mi2.getParams().get(0).getType().isNullable()); assertTrue(((ParameterizedTypeInfo) mi2.getParams().get(1).getType()).getArg(0).isNullable()); assertTrue(((ParameterizedTypeInfo) ((ParameterizedTypeInfo) mi2.getParams().get(2).getType()).getArg(0)).getArg(0).isNullable()); }; generateClass(check, MethodWithNullableInheritedParams.class, MethodWithNullableParams.class); generateClass(check, MethodWithNullableInheritedParams.class); }
Example #8
Source File: ClassNullableTest.java From vertx-codegen with Apache License 2.0 | 5 votes |
@Test public void testInterfaceWithListNullableParamOverride() throws Exception { generateClass(model -> { List<MethodInfo> methods = model.getMethods(); assertEquals(1, methods.size()); MethodInfo mi2 = methods.get(0); assertTrue(((ParameterizedTypeInfo) mi2.getParams().get(0).getType()).getArg(0).isNullable()); }, MethodWithListNullableParamOverride.class, MethodWithListNullableParam.class); }
Example #9
Source File: MethodInfo.java From vertx-codegen with Apache License 2.0 | 5 votes |
public TypeArgExpression resolveTypeArg(TypeVariableInfo typeVar) { for (TypeParamInfo.Method typeParam : typeParams) { if (typeParam.getName().equals(typeVar.getName())) { for (ParamInfo param : params) { if (param.getType().getKind() == ClassKind.CLASS_TYPE && param.getType().isParameterized()) { TypeInfo arg_ = ((ParameterizedTypeInfo) param.getType()).getArg(0); if (arg_.isVariable()) { TypeVariableInfo ttt = (TypeVariableInfo) arg_; if (ttt.getParam().equals(typeParam)) { return new TypeArgExpression(TypeArgExpression.CLASS_TYPE_ARG, ttt, param, 0); } } } else if (param.getType().getKind() == ClassKind.API && param.getType().isParameterized()) { ParameterizedTypeInfo type = (ParameterizedTypeInfo) param.getType(); int index = 0; for (TypeInfo i : type.getArgs()) { if (i instanceof TypeVariableInfo) { TypeVariableInfo tt = (TypeVariableInfo) i; if (tt.getParam().equals(typeParam)) { return new TypeArgExpression(TypeArgExpression.API_ARG, tt, param, index); } } index++; } } } return null; } } return null; }
Example #10
Source File: MethodInfo.java From vertx-codegen with Apache License 2.0 | 5 votes |
private static boolean containsAnyJavaType(TypeInfo type) { if (type instanceof ParameterizedTypeInfo) { return containsAnyJavaType(type.getRaw()) || ((ParameterizedTypeInfo) type).getArgs().stream().anyMatch(MethodInfo::containsAnyJavaType); } else { return type.getKind() == ClassKind.OTHER; } }
Example #11
Source File: MethodInfo.java From vertx-codegen with Apache License 2.0 | 5 votes |
public MethodKind getKind() { int lastParamIndex = params.size() - 1; if (lastParamIndex >= 0 && (returnType.isVoid() || fluent)) { TypeInfo lastParamType = params.get(lastParamIndex).type; if (lastParamType.getKind() == ClassKind.HANDLER) { TypeInfo typeArg = ((ParameterizedTypeInfo) lastParamType).getArgs().get(0); if (typeArg.getKind() == ClassKind.ASYNC_RESULT) { return MethodKind.FUTURE; } else { return MethodKind.HANDLER; } } } return MethodKind.OTHER; }
Example #12
Source File: TypeValidator.java From vertx-codegen with Apache License 2.0 | 5 votes |
private static boolean rawTypeIs(TypeInfo type, Class<?>... classes) { if (type instanceof ParameterizedTypeInfo) { String rawClassName = type.getRaw().getName(); for (Class<?> c : classes) { if (rawClassName.equals(c.getName())) { return true; } } } return false; }
Example #13
Source File: TypeValidator.java From vertx-codegen with Apache License 2.0 | 5 votes |
private static boolean isValidHandlerType(TypeInfo type, boolean allowAnyJavaType) { if (type.getErased().getKind() == ClassKind.HANDLER) { TypeInfo eventType = ((ParameterizedTypeInfo) type).getArgs().get(0); if (isValidCallbackValueType(eventType, allowAnyJavaType)) { return true; } else if (eventType.getErased().getKind() == ClassKind.ASYNC_RESULT && !eventType.isNullable()) { TypeInfo resultType = ((ParameterizedTypeInfo) eventType).getArgs().get(0); if (isValidCallbackValueType(resultType, allowAnyJavaType)) { return true; } } } return false; }
Example #14
Source File: TypeValidator.java From vertx-codegen with Apache License 2.0 | 5 votes |
private static boolean isValidFunctionType(TypeInfo typeInfo, boolean allowAnyJavaType) { if (typeInfo.getErased().getKind() == ClassKind.FUNCTION) { TypeInfo paramType = ((ParameterizedTypeInfo) typeInfo).getArgs().get(0); if (isValidCallbackValueType(paramType, allowAnyJavaType)) { TypeInfo returnType = ((ParameterizedTypeInfo) typeInfo).getArgs().get(1); return isValidNonCallableType(returnType, true, false, true, allowAnyJavaType); } } return false; }
Example #15
Source File: TypeValidator.java From vertx-codegen with Apache License 2.0 | 5 votes |
private static boolean isValidVertxGenInterface(TypeInfo type, boolean allowParameterized, boolean allowAnyJavaType) { if (type.getKind() == ClassKind.API) { if (type.isParameterized()) { ParameterizedTypeInfo parameterized = (ParameterizedTypeInfo) type; return allowParameterized && parameterized .getArgs() .stream() .noneMatch(arg -> !isValidVertxGenTypeArgument(arg, allowAnyJavaType) || arg.isNullable()); } else { return true; } } return false; }
Example #16
Source File: TypeValidator.java From vertx-codegen with Apache License 2.0 | 5 votes |
private static boolean isValidContainer(TypeInfo type, boolean allowAnyJavaType) { TypeInfo argument = null; if (rawTypeIs(type, List.class, Set.class, Map.class)) { ParameterizedTypeInfo parameterizedType = (ParameterizedTypeInfo) type; if (type.getKind() != ClassKind.MAP) { argument = parameterizedType.getArgs().get(0); } else if (parameterizedType.getArgs().get(0).getKind() == ClassKind.STRING) { // Only allow Map's with String's for keys argument= parameterizedType.getArgs().get(1); } } return argument != null && isValidContainerComponent(argument, allowAnyJavaType); }
Example #17
Source File: TypeValidator.java From vertx-codegen with Apache License 2.0 | 5 votes |
private static boolean isValidClassTypeParam(ExecutableElement elt, TypeInfo type) { if (type.getKind() == ClassKind.CLASS_TYPE && type.isParameterized()) { ParameterizedTypeInfo parameterized = (ParameterizedTypeInfo) type; TypeInfo arg = parameterized.getArg(0); if (arg.isVariable()) { TypeVariableInfo variable = (TypeVariableInfo) arg; for (TypeParameterElement typeParamElt : elt.getTypeParameters()) { if (typeParamElt.getSimpleName().toString().equals(variable.getName())) { return true; } } } } return false; }
Example #18
Source File: Helper.java From vertx-codetrans with Apache License 2.0 | 5 votes |
public static boolean isHandler(TypeInfo type) { if (type instanceof ParameterizedTypeInfo) { ParameterizedTypeInfo parameterizedType = (ParameterizedTypeInfo) type; return parameterizedType.getRaw().getName().equals(Handler.class.getName()); } return false; }
Example #19
Source File: ScalaCodeBuilder.java From vertx-codetrans with Apache License 2.0 | 5 votes |
@Override public ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo parameterizedTypeInfo, String s, CodeModel codeModel, CodeModel codeModel1, CodeModel codeModel2) { imports.add("scala.util.Failure"); imports.add("scala.util.Success"); return new ExpressionModel(this) { public void render(CodeWriter writer) { asyncResults.add(s); writer.append("{\n"); writer.indent(); writer.append("case Success(result) => "); writer.indent(); if (codeModel1 != null) { writer.append("{\n"); codeModel1.render(writer); writer.unindent(); writer.append("}\n"); } else { writer.append("println(\"Success\")\n"); writer.unindent(); } writer.append("case Failure(cause) => "); writer.indent(); if (codeModel2 != null) { writer.append("{\n"); writer.append("println(s\"$cause\")"); // codeModel2.render(writer) writer.unindent(); writer.append("\n}\n"); } else { writer.append("println(\"Failure\")\n"); writer.unindent(); } writer.unindent(); writer.append("}"); } }; }
Example #20
Source File: WebApiProxyModel.java From vertx-web with Apache License 2.0 | 5 votes |
@Override protected MethodInfo createMethodInfo(Set<ClassTypeInfo> ownerTypes, String methodName, String comment, Doc doc, TypeInfo returnType, Text returnDescription, boolean isFluent, boolean isCacheReturn, List<ParamInfo> mParams, ExecutableElement methodElt, boolean isStatic, boolean isDefault, ArrayList<TypeParamInfo.Method> typeParams, TypeElement declaringElt, boolean methodDeprecated, Text deprecatedDesc) { ProxyMethodInfo baseInfo = (ProxyMethodInfo) super.createMethodInfo(ownerTypes, methodName, comment, doc, returnType, returnDescription, isFluent, isCacheReturn, mParams, methodElt, isStatic, isDefault, typeParams, declaringElt, methodDeprecated, deprecatedDesc); if (!isStatic && !baseInfo.isProxyClose()) { // Check signature constraints TypeInfo ret; if (baseInfo.getKind() == MethodKind.FUTURE) { ret = ((ParameterizedTypeInfo) ((ParameterizedTypeInfo) mParams.get(mParams.size() - 1).getType()).getArg(0)).getArg(0); } else { throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR); } if (!ServiceResponse.class.getName().equals(ret.getName())) { throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR); } TypeInfo shouldBeServiceRequest; if (baseInfo.getKind() == MethodKind.FUTURE) { if (mParams.size() <= 1) { throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR); } shouldBeServiceRequest = mParams.get(mParams.size() - 2).getType(); } else { if (mParams.size() == 0) { throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR); } shouldBeServiceRequest = mParams.get(mParams.size() - 1).getType(); } if (!ServiceRequest.class.getName().equals(shouldBeServiceRequest.getName())) { throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR); } return new WebApiProxyMethodInfo(baseInfo); } else { return baseInfo; } }
Example #21
Source File: RxJava2Generator.java From vertx-rx with Apache License 2.0 | 5 votes |
private MethodInfo genOverloadedMethod(MethodInfo method, Class streamType) { List<ParamInfo> params = null; int count = 0; for (ParamInfo param : method.getParams()) { if (param.getType().isParameterized() && param.getType().getRaw().getName().equals("io.vertx.core.streams.ReadStream")) { if (params == null) { params = new ArrayList<>(method.getParams()); } ParameterizedTypeInfo paramType = new io.vertx.codegen.type.ParameterizedTypeInfo( io.vertx.codegen.type.TypeReflectionFactory.create(streamType).getRaw(), false, java.util.Collections.singletonList(((ParameterizedTypeInfo) param.getType()).getArg(0)) ); params.set(count, new io.vertx.codegen.ParamInfo( param.getIndex(), param.getName(), param.getDescription(), paramType )); } count = count + 1; } if (params != null) { return method.copy().setParams(params); } return null; }
Example #22
Source File: RxJavaGenerator.java From vertx-rx with Apache License 2.0 | 5 votes |
private MethodInfo genOverloadedMethod(MethodInfo method) { List<ParamInfo> params = null; int count = 0; for (ParamInfo param : method.getParams()) { if (param.getType().isParameterized() && param.getType().getRaw().getName().equals("io.vertx.core.streams.ReadStream")) { if (params == null) { params = new java.util.ArrayList<>(method.getParams()); } ParameterizedTypeInfo paramType = new io.vertx.codegen.type.ParameterizedTypeInfo( io.vertx.codegen.type.TypeReflectionFactory.create(rx.Observable.class).getRaw(), false, java.util.Collections.singletonList(((ParameterizedTypeInfo) param.getType()).getArg(0)) ); params.set(count, new io.vertx.codegen.ParamInfo( param.getIndex(), param.getName(), param.getDescription(), paramType )); } count = count + 1; } if (params != null) { return method.copy().setParams(params); } return null; }
Example #23
Source File: KotlinCodeBuilder.java From vertx-codetrans with Apache License 2.0 | 4 votes |
@Override public ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo resultType, String resultName, CodeModel body, CodeModel succeededBody, CodeModel failedBody) { return new LambdaExpressionModel(this, bodyKind, Collections.singletonList(resultType), Collections.singletonList(resultName), body); }
Example #24
Source File: GroovyCodeBuilder.java From vertx-codetrans with Apache License 2.0 | 4 votes |
@Override public ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo resultType, String resultName, CodeModel body, CodeModel succeededBody, CodeModel failedBody) { return new LambdaExpressionModel(this, bodyKind, Collections.singletonList(resultType), Collections.singletonList(resultName), body); }
Example #25
Source File: ScalaApiModel.java From vertx-codetrans with Apache License 2.0 | 4 votes |
private boolean methodAcceptsAsyncResultHandler(TypeInfo last) { return last.getKind() == ClassKind.HANDLER && ((ParameterizedTypeInfo) last).getArg(0).getKind() == ClassKind.ASYNC_RESULT; }
Example #26
Source File: ClassNullableTest.java From vertx-codegen with Apache License 2.0 | 4 votes |
@Test public void testMethodWithNullableTypeArgReturn() throws Exception { ClassModel model = new GeneratorHelper().generateClass(MethodWithNullableTypeArgReturn.class); List<MethodInfo> methods = model.getMethods(); assertEquals(36, methods.size()); checkMethod(methods.get(0), "listNullableByteReturn", 0, new TypeLiteral<List<Byte>>() {}, MethodKind.OTHER); checkMethod(methods.get(1), "listNullableShortReturn", 0, new TypeLiteral<List<Short>>() {}, MethodKind.OTHER); checkMethod(methods.get(2), "listNullableIntegerReturn", 0, new TypeLiteral<List<Integer>>() {}, MethodKind.OTHER); checkMethod(methods.get(3), "listNullableLongReturn", 0, new TypeLiteral<List<Long>>() {}, MethodKind.OTHER); checkMethod(methods.get(4), "listNullableFloatReturn", 0, new TypeLiteral<List<Float>>() {}, MethodKind.OTHER); checkMethod(methods.get(5), "listNullableDoubleReturn", 0, new TypeLiteral<List<Double>>() {}, MethodKind.OTHER); checkMethod(methods.get(6), "listNullableCharacterReturn", 0, new TypeLiteral<List<Character>>() {}, MethodKind.OTHER); checkMethod(methods.get(7), "listNullableStringReturn", 0, new TypeLiteral<List<String>>() {}, MethodKind.OTHER); checkMethod(methods.get(8), "listNullableJsonObjectReturn", 0, new TypeLiteral<List<JsonObject>>() {}, MethodKind.OTHER); checkMethod(methods.get(9), "listNullableJsonArrayReturn", 0, new TypeLiteral<List<JsonArray>>() {}, MethodKind.OTHER); checkMethod(methods.get(10), "listNullableEnumReturn", 0, new TypeLiteral<List<TestEnum>>() {}, MethodKind.OTHER); checkMethod(methods.get(11), "listNullableDataObjectReturn", 0, new TypeLiteral<List<TestDataObject>>() {}, MethodKind.OTHER); checkMethod(methods.get(12), "listNullableApiReturn", 0, new TypeLiteral<List<VertxGenClass1>>() {}, MethodKind.OTHER); checkMethod(methods.get(13), "setNullableByteReturn", 0, new TypeLiteral<Set<Byte>>() {}, MethodKind.OTHER); checkMethod(methods.get(14), "setNullableShortReturn", 0, new TypeLiteral<Set<Short>>() {}, MethodKind.OTHER); checkMethod(methods.get(15), "setNullableIntegerReturn", 0, new TypeLiteral<Set<Integer>>() {}, MethodKind.OTHER); checkMethod(methods.get(16), "setNullableLongReturn", 0, new TypeLiteral<Set<Long>>() {}, MethodKind.OTHER); checkMethod(methods.get(17), "setNullableFloatReturn", 0, new TypeLiteral<Set<Float>>() {}, MethodKind.OTHER); checkMethod(methods.get(18), "setNullableDoubleReturn", 0, new TypeLiteral<Set<Double>>() {}, MethodKind.OTHER); checkMethod(methods.get(19), "setNullableCharacterReturn", 0, new TypeLiteral<Set<Character>>() {}, MethodKind.OTHER); checkMethod(methods.get(20), "setNullableStringReturn", 0, new TypeLiteral<Set<String>>() {}, MethodKind.OTHER); checkMethod(methods.get(21), "setNullableJsonObjectReturn", 0, new TypeLiteral<Set<JsonObject>>() {}, MethodKind.OTHER); checkMethod(methods.get(22), "setNullableJsonArrayReturn", 0, new TypeLiteral<Set<JsonArray>>() {}, MethodKind.OTHER); checkMethod(methods.get(23), "setNullableEnumReturn", 0, new TypeLiteral<Set<TestEnum>>() {}, MethodKind.OTHER); checkMethod(methods.get(24), "setNullableDataObjectReturn", 0, new TypeLiteral<Set<TestDataObject>>() {}, MethodKind.OTHER); checkMethod(methods.get(25), "setNullableApiReturn", 0, new TypeLiteral<Set<VertxGenClass1>>() {}, MethodKind.OTHER); checkMethod(methods.get(26), "mapNullableByteReturn", 0, new TypeLiteral<Map<String, Byte>>() {}, MethodKind.OTHER); checkMethod(methods.get(27), "mapNullableShortReturn", 0, new TypeLiteral<Map<String, Short>>() {}, MethodKind.OTHER); checkMethod(methods.get(28), "mapNullableIntegerReturn", 0, new TypeLiteral<Map<String, Integer>>() {}, MethodKind.OTHER); checkMethod(methods.get(29), "mapNullableLongReturn", 0, new TypeLiteral<Map<String, Long>>() {}, MethodKind.OTHER); checkMethod(methods.get(30), "mapNullableFloatReturn", 0, new TypeLiteral<Map<String, Float>>() {}, MethodKind.OTHER); checkMethod(methods.get(31), "mapNullableDoubleReturn", 0, new TypeLiteral<Map<String, Double>>() {}, MethodKind.OTHER); checkMethod(methods.get(32), "mapNullableCharacterReturn", 0, new TypeLiteral<Map<String, Character>>() {}, MethodKind.OTHER); checkMethod(methods.get(33), "mapNullableStringReturn", 0, new TypeLiteral<Map<String, String>>() {}, MethodKind.OTHER); checkMethod(methods.get(34), "mapNullableJsonObjectReturn", 0, new TypeLiteral<Map<String, JsonObject>>() {}, MethodKind.OTHER); checkMethod(methods.get(35), "mapNullableJsonArrayReturn", 0, new TypeLiteral<Map<String, JsonArray>>() {}, MethodKind.OTHER); methods.forEach(m -> { assertFalse("Expects " + m.getName() + " to have nullable return type", m.isNullableReturn()); List<TypeInfo> args = ((ParameterizedTypeInfo) m.getReturnType()).getArgs(); assertTrue("Expects " + m.getName() + " to have nullable return type", args.get(args.size() - 1).isNullable()); }); }
Example #27
Source File: GeneratorUtils.java From vertx-service-proxy with Apache License 2.0 | 4 votes |
public boolean isResultHandler(ParamInfo param) { return param != null && param.getType().getKind() == ClassKind.HANDLER && ((ParameterizedTypeInfo)param.getType()).getArg(0).getKind() == ClassKind.ASYNC_RESULT; }
Example #28
Source File: CodeBuilder.java From vertx-codetrans with Apache License 2.0 | votes |
ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo resultType, String resultName, CodeModel body, CodeModel succeededBody, CodeModel failedBody);