Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.checkerframework.checker.nullness.qual.NonNull;

/**
* An object in Google Cloud Storage. A {@code Blob} object includes the {@code BlobId} instance,
Expand Down Expand Up @@ -128,7 +129,7 @@ public static BlobSourceOption metagenerationNotMatch() {
* blob.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobSourceOption decryptionKey(Key key) {
public static BlobSourceOption decryptionKey(@NonNull Key key) {
return new BlobSourceOption(UnifiedOpts.decryptionKey(key));
}

Expand All @@ -139,7 +140,7 @@ public static BlobSourceOption decryptionKey(Key key) {
* @param key the AES256 encoded in base64
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobSourceOption decryptionKey(String key) {
public static BlobSourceOption decryptionKey(@NonNull String key) {
return new BlobSourceOption(UnifiedOpts.decryptionKey(key));
}

Expand All @@ -148,7 +149,7 @@ public static BlobSourceOption decryptionKey(String key) {
* bucket has requester_pays flag enabled.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobSourceOption userProject(String userProject) {
public static BlobSourceOption userProject(@NonNull String userProject) {
return new BlobSourceOption(UnifiedOpts.userProject(userProject));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.checkerframework.checker.nullness.qual.NonNull;

/**
* A Google cloud storage bucket.
Expand Down Expand Up @@ -93,7 +94,7 @@ public static BucketSourceOption metagenerationNotMatch() {
* with 'requester_pays' flag.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BucketSourceOption userProject(String userProject) {
public static BucketSourceOption userProject(@NonNull String userProject) {
return new BucketSourceOption(UnifiedOpts.userProject(userProject));
}

Expand Down Expand Up @@ -142,7 +143,7 @@ private BlobTargetOption(ObjectTargetOpt opt) {

/** 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
Collaborator

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
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

return new BlobTargetOption(UnifiedOpts.predefinedAcl(acl));
}

Expand Down Expand Up @@ -201,7 +202,7 @@ public static BlobTargetOption metagenerationNotMatch(long metageneration) {
* blob.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobTargetOption encryptionKey(Key key) {
public static BlobTargetOption encryptionKey(@NonNull Key key) {
return new BlobTargetOption(UnifiedOpts.encryptionKey(key));
}

Expand All @@ -212,7 +213,7 @@ public static BlobTargetOption encryptionKey(Key key) {
* @param key the AES256 encoded in base64
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobTargetOption encryptionKey(String key) {
public static BlobTargetOption encryptionKey(@NonNull String key) {
return new BlobTargetOption(UnifiedOpts.encryptionKey(key));
}

Expand All @@ -222,7 +223,7 @@ public static BlobTargetOption encryptionKey(String key) {
* @param kmsKeyName the KMS key resource id
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobTargetOption kmsKeyName(String kmsKeyName) {
public static BlobTargetOption kmsKeyName(@NonNull String kmsKeyName) {
return new BlobTargetOption(UnifiedOpts.kmsKeyName(kmsKeyName));
}

Expand All @@ -231,7 +232,7 @@ public static BlobTargetOption kmsKeyName(String kmsKeyName) {
* with 'requester_pays' flag.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobTargetOption userProject(String userProject) {
public static BlobTargetOption userProject(@NonNull String userProject) {
return new BlobTargetOption(UnifiedOpts.userProject(userProject));
}

Expand Down Expand Up @@ -263,7 +264,7 @@ private BlobWriteOption(ObjectTargetOpt opt) {

/** Returns an option for specifying blob's predefined ACL configuration. */
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobWriteOption predefinedAcl(Storage.PredefinedAcl acl) {
public static BlobWriteOption predefinedAcl(Storage.@NonNull PredefinedAcl acl) {
return new BlobWriteOption(UnifiedOpts.predefinedAcl(acl));
}

Expand Down Expand Up @@ -322,7 +323,7 @@ public static BlobWriteOption metagenerationNotMatch(long metageneration) {
* fail if blobs' data MD5 hash does not match the provided value.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobWriteOption md5Match(String md5) {
public static BlobWriteOption md5Match(@NonNull String md5) {
return new BlobWriteOption(UnifiedOpts.md5Match(md5));
}

Expand All @@ -331,7 +332,7 @@ public static BlobWriteOption md5Match(String md5) {
* will fail if blobs' data CRC32C checksum does not match the provided value.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobWriteOption crc32cMatch(String crc32c) {
public static BlobWriteOption crc32cMatch(@NonNull String crc32c) {
return new BlobWriteOption(UnifiedOpts.crc32cMatch(crc32c));
}

Expand All @@ -340,7 +341,7 @@ public static BlobWriteOption crc32cMatch(String crc32c) {
* blob.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobWriteOption encryptionKey(Key key) {
public static BlobWriteOption encryptionKey(@NonNull Key key) {
return new BlobWriteOption(UnifiedOpts.encryptionKey(key));
}

Expand All @@ -351,7 +352,7 @@ public static BlobWriteOption encryptionKey(Key key) {
* @param key the AES256 encoded in base64
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobWriteOption encryptionKey(String key) {
public static BlobWriteOption encryptionKey(@NonNull String key) {
return new BlobWriteOption(UnifiedOpts.encryptionKey(key));
}

Expand All @@ -360,7 +361,7 @@ public static BlobWriteOption encryptionKey(String key) {
* with 'requester_pays' flag.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobWriteOption userProject(String userProject) {
public static BlobWriteOption userProject(@NonNull String userProject) {
return new BlobWriteOption(UnifiedOpts.userProject(userProject));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ public static DeleteLifecycleAction newDeleteAction() {
* @param storageClass The new storage class to use when conditions are met for this action.
*/
public static SetStorageClassLifecycleAction newSetStorageClassAction(
StorageClass storageClass) {
@NonNull StorageClass storageClass) {
return new SetStorageClassLifecycleAction(storageClass);
}

Expand All @@ -1080,7 +1080,7 @@ public static LifecycleAction newAbortIncompleteMPUploadAction() {
* generally not be used, instead use the supported actions, and upgrade the library if necessary
* to get new supported actions.
*/
public static LifecycleAction newLifecycleAction(String actionType) {
public static LifecycleAction newLifecycleAction(@NonNull String actionType) {
return new LifecycleAction(actionType);
}
}
Expand Down