vertx-lang-kotlin icon indicating copy to clipboard operation
vertx-lang-kotlin copied to clipboard

Force Vertx Rx CodeGen To Generate MayBe As Return Type(Kotlin)

Open c-nnooka opened this issue 6 years ago • 0 comments

I am using following Kotlin code to generate proxy (This will also generate Rx methods)

@ProxyGen
@VertxGen
interface JobService {
    @Fluent
    fun getCertain(jobId: Int, handler: Handler<AsyncResult<Job?>>): JobService
}

When I see generated Rx Code it is as follows.

public Single<Job> rxGetCertain(int jobId) { 
   return new io.vertx.reactivex.core.impl.AsyncResultSingle<Job>(handler -> {
     getCertain(jobId, handler);
   });
}

Issue:-

Unfortunately i am not able to use this in Kotlin as kotlin won't allow null values for non-null fields and it is throwing following exception.

java.lang.IllegalArgumentException: Parameter specified as non-null is null

How do i force Vertx CodeGen to generate return type as MayBe so that my code works without any issues in kotlin.

Note: I have tried adding @Nullable but no use

i have added Sample Project Here

https://github.com/c-nnooka/VertxCodeGenMayBe

c-nnooka avatar Jul 30 '18 13:07 c-nnooka