sdk-java: Returning empty values
From https://github.com/cloudevents/sdk-java/issues/119 and https://github.com/cloudevents/sdk-java/pull/108#discussion_r411193730:
What technique should we use, around the sdk, to notify the user of an eventual empty return value?
Optionalgetters- Have an annotation called
@Nullablewhich notifies the user of an eventual null return value - Just explicit in the Javadoc that a method can return null
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (16 by maintainers)
Commits related to this issue
- Introduce JSR-305 compatible nullability, remove `Optional` Closes #123. Signed-off-by: Sergei Egorov <segorov@pivotal.io> — committed to bsideup/sdk-java by bsideup 4 years ago
- Introduce JSR-305 compatible nullability, remove `Optional` (#138) * Introduce JSR-305 compatible nullability, remove `Optional` Closes #123. Signed-off-by: Sergei Egorov <segorov@pivotal.io> ... — committed to cloudevents/sdk-java by bsideup 4 years ago
I would love to, to keep consistency across our modules
@slinkydeveloper I would agree with you if not the usages tab of that dependency where you will find a ton of major Java projects 😉
Sure! Expect a PR soon
One of the most commonly used is https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305/3.0.2/usages
Spring Framework and other top Java projects are using it: https://github.com/spring-projects/spring-framework/blob/8265db0ae1d83a1e204e602fa96e542c2677977f/build.gradle#L348
Kotlin supports it too: https://kotlinlang.org/docs/reference/java-interop.html#nullability-annotations
Note that it is just a set of annotations.