docs: annotate all Option factory methods with their Nullability bounds - #1775
Merged
Conversation
Update all option factory methods to explicitly state their Nullability bounds. All methods which take non-primitive parameters are @nonnull, and will be published in the javadocs. Add new tests to explicitly verify null argument validation. All factory methods now check their args for nullness, instead of depending on implicit checking.
sydney-munro
approved these changes
Nov 17, 2022
| /** Returns an option for specifying blob's predefined ACL configuration. */ | ||
| @TransportCompatibility({Transport.HTTP, Transport.GRPC}) | ||
| public static BlobTargetOption predefinedAcl(Storage.PredefinedAcl acl) { | ||
| public static BlobTargetOption predefinedAcl(Storage.@NonNull PredefinedAcl acl) { |
Contributor
There was a problem hiding this comment.
nit: can this not look like
public static BlobTargetOption predefinedAcl(@NonNull Storage.PredefinedAcl acl)
Collaborator
Author
There was a problem hiding this comment.
The @NonNull is applicable to a type, not the method parameter. So it needs to immediately precede the type, in this case PredefinedAcl which happens to be nested in Storage.
If the annotation is moved before Storage it will result in a compile error:
.../google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java:146:66
java: scoping construct cannot be annotated with type-use annotation: @org.checkerframework.checker.nullness.qual.NonNull
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update all option factory methods to explicitly state their Nullability bounds. All methods which take non-primitive parameters are @nonnull, and will be published in the javadocs.
Add new tests to explicitly verify null argument validation.
All factory methods now check their args for nullness, instead of depending on implicit checking.