public TypeInfo getHandlerType() { return (type.getKind() == ClassKind.API) ? ((ApiTypeInfo)type).getHandlerArg() : null; }
@Test public void testInterfaceExtendingHandlerStringSubtype() throws Exception { ClassModel model = new GeneratorHelper().generateClass(InterfaceExtendingHandlerStringSubtype.class); TypeInfo handlerSuperType = model.getHandlerType(); assertEquals(TypeReflectionFactory.create(String.class), handlerSuperType); ApiTypeInfo apiType = (ApiTypeInfo) model.getType(); assertTrue(apiType.isHandler()); assertEquals(TypeReflectionFactory.create(String.class), apiType.getHandlerArg()); assertFalse(apiType.isReadStream()); assertFalse(apiType.isWriteStream()); assertEquals(1, model.getMethodMap().size()); assertEquals(1, model.getMethodMap().get("handle").size()); checkMethod(model.getMethodMap().get("handle").get(0), "handle", 1, "void", MethodKind.OTHER); }
@Test public void testInterfaceExtendingHandlerVertxGenSubtype() throws Exception { ClassModel model = new GeneratorHelper().generateClass(InterfaceExtendingHandlerVertxGenSubtype.class, VertxGenClass1.class); TypeInfo handlerSuperType = model.getHandlerType(); assertEquals(TypeReflectionFactory.create(VertxGenClass1.class), handlerSuperType); ApiTypeInfo apiType = (ApiTypeInfo) model.getType(); assertTrue(apiType.isHandler()); assertEquals(TypeReflectionFactory.create(VertxGenClass1.class), apiType.getHandlerArg()); assertFalse(apiType.isReadStream()); assertFalse(apiType.isWriteStream()); assertEquals(1, model.getMethodMap().size()); assertEquals(1, model.getMethodMap().get("handle").size()); checkMethod(model.getMethodMap().get("handle").get(0), "handle", 1, "void", MethodKind.OTHER); }