我使用下面的Kotlin代码来生成代理(这也将生成Rx方法)
@ProxyGen
@VertxGen
interface JobService {
@Fluent
fun getCertain(jobId: Int, handler: Handler<AsyncResult<Job?>>): JobService
}当我看到生成的Rx代码时,如下所示。
public Single<Job> rxGetCertain(int jobId) {
return new io.vertx.reactivex.core.impl.AsyncResultSingle<Job>(handler -> {
getCertain(jobId, handler);
});
}发行:-
不幸的是,我无法在Kotlin中使用它,因为kotlin不允许非空字段的空值,它将抛出以下异常。
java.lang.IllegalArgumentException: Parameter specified as non-null is null如何强制Vertx CodeGen以MayBe的形式生成返回类型,使我的代码在kotlin中没有任何问题。
发布于 2019-02-01 08:00:01
添加年历@Nullable
@ProxyGen
@VertxGen
interface JobService {
@Fluent
fun getCertain(jobId: Int, handler: Handler<AsyncResult<@Nullable Job?>>): JobService
}https://stackoverflow.com/questions/51368000
复制相似问题