OpenAPITools/jackson-databind-nullable

Add convenient Optional.orElse() like getter to JsonNullable

hatzlj opened this issue · 1 comments

First of all thanks for including the nullable support in OpenAPITools.
I would like to suggest a minor improvement to the API of JsonNullable.

Currently we would need to use something like

jsonNullableString.isPresent() ? jsonNullableString.get() : null

to allow inline usage of the value.

Having someting like java Optional's .orElse() would make inline usage of JsonNullable easier.

public T orElse(T other) {
  return this.isPresent ? this.value : other;
}        

What do you think? If you like this idea, I would be happy to submit a PR to this project.

thanks,
Jakob

Yes, seems like a good idea. Your PR is welcome 😃