Skip to content

docs: annotate all Option factory methods with their Nullability bounds - #1775

Merged
BenWhitehead merged 1 commit into
mainfrom
opts/filter-out-null-values
Nov 17, 2022
Merged

docs: annotate all Option factory methods with their Nullability bounds#1775
BenWhitehead merged 1 commit into
mainfrom
opts/filter-out-null-values

Conversation

@BenWhitehead

Copy link
Copy Markdown
Collaborator

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.

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.
@BenWhitehead
BenWhitehead requested a review from a team November 16, 2022 23:27
@product-auto-label product-auto-label Bot added size: l Pull request size is large. api: storage Issues related to the googleapis/java-storage API. labels Nov 16, 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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can this not look like
public static BlobTargetOption predefinedAcl(@NonNull Storage.PredefinedAcl acl)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@BenWhitehead
BenWhitehead merged commit 3b8d137 into main Nov 17, 2022
@BenWhitehead
BenWhitehead deleted the opts/filter-out-null-values branch November 17, 2022 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the googleapis/java-storage API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants