Wesley Acheson
07/15/2020, 9:53 AMoverride fun load(id: String): Mono<StoredRequest?> {
val storedRequest: StoredRequest? = memory[id]
return Mono.just(null);
}
However it doesn't allow me to return a Mono of null here or even return the value from the backing map.
As far as I understand the method signature I've given a null should be allowed.
Is there any way to force the java like behaviour?tddmonkey
07/15/2020, 9:59 AMWesley Acheson
07/15/2020, 9:59 AMval something = repository.load("Not found").block()
println(something)
tddmonkey
07/15/2020, 10:03 AMnull
there from an empty monotddmonkey
07/15/2020, 10:03 AMMono.empty()
Wesley Acheson
07/15/2020, 10:06 AMoverride fun load(id: String): Mono<StoredRequest?> {
val storedRequest: StoredRequest? = memory[id]
return if (storedRequest != null) Mono.just(storedRequest) else Mono.empty()
}
Works thank you. I think I should be able to use let there but I'm making a hash of it. (no pun intended)Wesley Acheson
07/15/2020, 10:16 AMoverride fun load(id: String) = memory[id]?.let { Mono.just(it) }?: Mono.empty()
tddmonkey
07/15/2020, 10:20 AMMono.justOrEmpty(nullableValue)