Add section to coding guidelines on Optional usage (#6894)

This was discussed a long while back, but never documented (and recently
came up in #6889)

Co-authored-by: Fabrizio Ferri-Benedetti <fferribenedetti@splunk.com>
This commit is contained in:
Trask Stalnaker 2022-10-22 18:07:00 -07:00 committed by GitHub
parent 9ce68fb937
commit d18a05b5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -126,3 +126,11 @@ plugins {
id("otel.nullaway-conventions") id("otel.nullaway-conventions")
} }
``` ```
## java.util.Optional usage
Following the reasoning from [Writing a Java library with better experience (slide 12)](https://speakerdeck.com/trustin/writing-a-java-library-with-better-experience?slide=12),
usage of `java.util.Optional` is kept at a minimum in this project.
It is ok to use `Optional` in places where it does not leak into public API signatures and where
performance is not critical.