Skip to content

Commit 68b0a3d

Browse files
committed
Use checkArgument instead of throw, better javadoc
1 parent 1410494 commit 68b0a3d

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java

+18-16
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ public Builder sourceOptions(Iterable<BlobSourceOption> options) {
551551
}
552552

553553
/**
554-
* Sets the copy target.
554+
* Sets the copy target. Target blob information is copied from source.
555555
*
556556
* @return the builder.
557557
*/
@@ -561,8 +561,9 @@ public Builder target(BlobId target) {
561561
}
562562

563563
/**
564-
* Sets the copy target and target options. Copied blob metadata is set to {@code target}.
565-
* This method throws an exception if target blob's content type is {@code null}.
564+
* Sets the copy target and target options. {@code target} parameter is used to override
565+
* source blob information (e.g. {@code contentType}, {@code contentLanguage}). {@code
566+
* target.contentType} is a required field.
566567
*
567568
* @return the builder.
568569
* @throws IllegalArgumentException if {@code target.contentType} is {@code null}
@@ -576,8 +577,9 @@ public Builder target(BlobInfo target, BlobTargetOption... options)
576577
}
577578

578579
/**
579-
* Sets the copy target and target options. Copied blob metadata is set to {@code target}.
580-
* This method throws an exception if target blob's content type is {@code null}.
580+
* Sets the copy target and target options. {@code target} parameter is used to override
581+
* source blob information (e.g. {@code contentType}, {@code contentLanguage}). {@code
582+
* target.contentType} is a required field.
581583
*
582584
* @return the builder.
583585
* @throws IllegalArgumentException if {@code target.contentType} is {@code null}
@@ -658,8 +660,9 @@ public Long megabytesCopiedPerChunk() {
658660
}
659661

660662
/**
661-
* Creates a copy request. Copied blob metadata is set to {@code target}. This method throws an
662-
* exception if target blob's content type is {@code null}.
663+
* Creates a copy request. {@code target} parameter is used to override source blob information
664+
* (e.g. {@code contentType}, {@code contentLanguage}). {@code target.contentType} is a required
665+
* field.
663666
*
664667
* @param sourceBucket name of the bucket containing the source blob
665668
* @param sourceBlob name of the source blob
@@ -674,8 +677,9 @@ public static CopyRequest of(String sourceBucket, String sourceBlob, BlobInfo ta
674677
}
675678

676679
/**
677-
* Creates a copy request. Copied blob metadata is set to {@code target}. This method throws an
678-
* exception if target blob's content type is {@code null}.
680+
* Creates a copy request. {@code target} parameter is used to override source blob information
681+
* (e.g. {@code contentType}, {@code contentLanguage}). {@code target.contentType} is a required
682+
* field.
679683
*
680684
* @param sourceBlobId a {@code BlobId} object for the source blob
681685
* @param target a {@code BlobInfo} object for the target blob
@@ -689,7 +693,7 @@ public static CopyRequest of(BlobId sourceBlobId, BlobInfo target)
689693
}
690694

691695
/**
692-
* Creates a copy request.
696+
* Creates a copy request. Target blob information is copied from source.
693697
*
694698
* @param sourceBucket name of the bucket containing both the source and the target blob
695699
* @param sourceBlob name of the source blob
@@ -704,7 +708,7 @@ public static CopyRequest of(String sourceBucket, String sourceBlob, String targ
704708
}
705709

706710
/**
707-
* Creates a copy request.
711+
* Creates a copy request. Target blob information is copied from source.
708712
*
709713
* @param sourceBucket name of the bucket containing the source blob
710714
* @param sourceBlob name of the source blob
@@ -716,7 +720,7 @@ public static CopyRequest of(String sourceBucket, String sourceBlob, BlobId targ
716720
}
717721

718722
/**
719-
* Creates a copy request.
723+
* Creates a copy request. Target blob information is copied from source.
720724
*
721725
* @param sourceBlobId a {@code BlobId} object for the source blob
722726
* @param targetBlob name of the target blob, in the same bucket of the source blob
@@ -730,7 +734,7 @@ public static CopyRequest of(BlobId sourceBlobId, String targetBlob) {
730734
}
731735

732736
/**
733-
* Creates a copy request.
737+
* Creates a copy request. Target blob information is copied from source.
734738
*
735739
* @param sourceBlobId a {@code BlobId} object for the source blob
736740
* @param targetBlobId a {@code BlobId} object for the target blob
@@ -748,9 +752,7 @@ public static Builder builder() {
748752
}
749753

750754
private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentException {
751-
if (blobInfo.contentType() == null) {
752-
throw new IllegalArgumentException("Blob content type can not be null");
753-
}
755+
checkArgument(blobInfo.contentType() != null, "Blob content type can not be null");
754756
}
755757
}
756758

gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyRequestTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ public void testCopyRequestOfStringFail() {
126126
Storage.CopyRequest.of(
127127
SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME, BlobInfo.builder(TARGET_BLOB_ID).build());
128128
}
129-
}
129+
}

0 commit comments

Comments
 (0)