From 2880af350d86c195e63e6bc2f625b8d09b852708 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sat, 22 Oct 2022 18:07:00 -0700 Subject: [PATCH] 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 --- docs/contributing/style-guideline.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/contributing/style-guideline.md b/docs/contributing/style-guideline.md index 8f647164a6c3..2b54b53fa20b 100644 --- a/docs/contributing/style-guideline.md +++ b/docs/contributing/style-guideline.md @@ -126,3 +126,11 @@ plugins { 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.