Skip to content

Commit

Permalink
Use checkArgument instead of throw, better javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Oct 30, 2015
1 parent 1410494 commit ca2ffa3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ public Builder sourceOptions(Iterable<BlobSourceOption> options) {
}

/**
* Sets the copy target.
* Sets the copy target. Target blob information is copied from source.
*
* @return the builder.
*/
Expand All @@ -561,8 +561,9 @@ public Builder target(BlobId target) {
}

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

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

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

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

/**
* Creates a copy request.
* Creates a copy request. Target blob information is copied from source.
*
* @param sourceBucket name of the bucket containing both the source and the target blob
* @param sourceBlob name of the source blob
Expand All @@ -704,7 +708,7 @@ public static CopyRequest of(String sourceBucket, String sourceBlob, String targ
}

/**
* Creates a copy request.
* Creates a copy request. Target blob information is copied from source.
*
* @param sourceBucket name of the bucket containing the source blob
* @param sourceBlob name of the source blob
Expand All @@ -716,7 +720,7 @@ public static CopyRequest of(String sourceBucket, String sourceBlob, BlobId targ
}

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

/**
* Creates a copy request.
* Creates a copy request. Target blob information is copied from source.
*
* @param sourceBlobId a {@code BlobId} object for the source blob
* @param targetBlobId a {@code BlobId} object for the target blob
Expand All @@ -748,9 +752,7 @@ public static Builder builder() {
}

private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentException {
if (blobInfo.contentType() == null) {
throw new IllegalArgumentException("Blob content type can not be null");
}
checkArgument(blobInfo.contentType() != null, "Blob content type can not be null");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ public void testCopyRequestOfStringFail() {
Storage.CopyRequest.of(
SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME, BlobInfo.builder(TARGET_BLOB_ID).build());
}
}
}

0 comments on commit ca2ffa3

Please sign in to comment.