Skip to content

Commit aa0e377

Browse files
author
Ajay Kannan
committed
minor fixes
1 parent 3d1c1c8 commit aa0e377

9 files changed

Lines changed: 146 additions & 182 deletions

File tree

gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Project extends ProjectInfo {
4040

4141
public static class Builder extends ProjectInfo.Builder {
4242
private final ResourceManager resourceManager;
43-
private ProjectInfo.BuilderImpl infoBuilder;
43+
private final ProjectInfo.BuilderImpl infoBuilder;
4444

4545
Builder(ResourceManager resourceManager) {
4646
this.resourceManager = resourceManager;

gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ProjectInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static ResourceId fromPb(
115115
}
116116
}
117117

118-
public static abstract class Builder {
118+
public abstract static class Builder {
119119

120120
/**
121121
* Set the user-assigned name of the project.

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ public Blob apply(Tuple<Storage, StorageObject> pb) {
6363
return Blob.fromPb(pb.x(), pb.y());
6464
}
6565
};
66-
static final Function<Blob, StorageObject> BLOB_TO_PB_FUNCTION = new Function<Blob, StorageObject>() {
67-
@Override
68-
public StorageObject apply(Blob blob) {
69-
return blob.toPb();
70-
}
71-
};
66+
static final Function<Blob, StorageObject> BLOB_TO_PB_FUNCTION =
67+
new Function<Blob, StorageObject>() {
68+
@Override
69+
public StorageObject apply(Blob blob) {
70+
return blob.toPb();
71+
}
72+
};
7273

7374
/**
7475
* Class for specifying blob source options when {@code Blob} methods are used.
@@ -166,7 +167,7 @@ static Storage.BlobGetOption[] toGetOptions(BlobInfo blobInfo, BlobSourceOption.
166167
public static class Builder extends BlobInfo.Builder {
167168

168169
private final Storage storage;
169-
private BlobInfo.BuilderImpl infoBuilder;
170+
private final BlobInfo.BuilderImpl infoBuilder;
170171

171172
Builder(Storage storage) {
172173
this.storage = storage;
@@ -393,12 +394,11 @@ public boolean delete(BlobSourceOption... options) {
393394
* @throws StorageException upon failure
394395
*/
395396
public CopyWriter copyTo(BlobId targetBlob, BlobSourceOption... options) {
396-
CopyRequest copyRequest =
397-
CopyRequest.builder()
398-
.source(bucket(), name())
399-
.sourceOptions(toSourceOptions(this, options))
400-
.target(targetBlob)
401-
.build();
397+
CopyRequest copyRequest = CopyRequest.builder()
398+
.source(bucket(), name())
399+
.sourceOptions(toSourceOptions(this, options))
400+
.target(targetBlob)
401+
.build();
402402
return storage.copy(copyRequest);
403403
}
404404

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

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public Set<Entry<K, V>> entrySet() {
9797
}
9898
}
9999

100-
public static abstract class Builder {
100+
public abstract static class Builder {
101101

102102
/**
103103
* Sets the blob identity.
@@ -245,9 +245,6 @@ static final class BuilderImpl extends Builder {
245245
updateTime = blobInfo.updateTime;
246246
}
247247

248-
/**
249-
* Sets the blob identity.
250-
*/
251248
@Override
252249
public Builder blobId(BlobId blobId) {
253250
this.blobId = checkNotNull(blobId);
@@ -260,44 +257,24 @@ Builder id(String id) {
260257
return this;
261258
}
262259

263-
/**
264-
* Sets the blob's data content type.
265-
*
266-
* @see <a href="https://tools.ietf.org/html/rfc2616#section-14.17">Content-Type</a>
267-
*/
268260
@Override
269261
public Builder contentType(String contentType) {
270262
this.contentType = firstNonNull(contentType, Data.<String>nullOf(String.class));
271263
return this;
272264
}
273265

274-
/**
275-
* Sets the blob's data content disposition.
276-
*
277-
* @see <a href="https://tools.ietf.org/html/rfc6266">Content-Disposition</a>
278-
*/
279266
@Override
280267
public Builder contentDisposition(String contentDisposition) {
281268
this.contentDisposition = firstNonNull(contentDisposition, Data.<String>nullOf(String.class));
282269
return this;
283270
}
284271

285-
/**
286-
* Sets the blob's data content language.
287-
*
288-
* @see <a href="http://tools.ietf.org/html/bcp47">Content-Language</a>
289-
*/
290272
@Override
291273
public Builder contentLanguage(String contentLanguage) {
292274
this.contentLanguage = firstNonNull(contentLanguage, Data.<String>nullOf(String.class));
293275
return this;
294276
}
295277

296-
/**
297-
* Sets the blob's data content encoding.
298-
*
299-
* @see <a href="https://tools.ietf.org/html/rfc7231#section-3.1.2.2">Content-Encoding</a>
300-
*/
301278
@Override
302279
public Builder contentEncoding(String contentEncoding) {
303280
this.contentEncoding = firstNonNull(contentEncoding, Data.<String>nullOf(String.class));
@@ -310,23 +287,12 @@ Builder componentCount(Integer componentCount) {
310287
return this;
311288
}
312289

313-
/**
314-
* Sets the blob's data cache control.
315-
*
316-
* @see <a href="https://tools.ietf.org/html/rfc7234#section-5.2">Cache-Control</a>
317-
*/
318290
@Override
319291
public Builder cacheControl(String cacheControl) {
320292
this.cacheControl = firstNonNull(cacheControl, Data.<String>nullOf(String.class));
321293
return this;
322294
}
323295

324-
/**
325-
* Sets the blob's access control configuration.
326-
*
327-
* @see <a href="https://cloud.google.com/storage/docs/access-control#About-Access-Control-Lists">
328-
* About Access Control Lists</a>
329-
*/
330296
@Override
331297
public Builder acl(List<Acl> acl) {
332298
this.acl = acl != null ? ImmutableList.copyOf(acl) : null;
@@ -357,26 +323,12 @@ Builder selfLink(String selfLink) {
357323
return this;
358324
}
359325

360-
/**
361-
* Sets the MD5 hash of blob's data. MD5 value must be encoded in base64.
362-
*
363-
* @see <a href="https://cloud.google.com/storage/docs/hashes-etags#_JSONAPI">
364-
* Hashes and ETags: Best Practices</a>
365-
*/
366326
@Override
367327
public Builder md5(String md5) {
368328
this.md5 = firstNonNull(md5, Data.<String>nullOf(String.class));
369329
return this;
370330
}
371331

372-
/**
373-
* Sets the CRC32C checksum of blob's data as described in
374-
* <a href="http://tools.ietf.org/html/rfc4960#appendix-B">RFC 4960, Appendix B;</a> encoded in
375-
* base64 in big-endian order.
376-
*
377-
* @see <a href="https://cloud.google.com/storage/docs/hashes-etags#_JSONAPI">
378-
* Hashes and ETags: Best Practices</a>
379-
*/
380332
@Override
381333
public Builder crc32c(String crc32c) {
382334
this.crc32c = firstNonNull(crc32c, Data.<String>nullOf(String.class));
@@ -389,9 +341,6 @@ Builder mediaLink(String mediaLink) {
389341
return this;
390342
}
391343

392-
/**
393-
* Sets the blob's user provided metadata.
394-
*/
395344
@Override
396345
public Builder metadata(Map<String, String> metadata) {
397346
this.metadata = metadata != null
@@ -417,9 +366,6 @@ Builder updateTime(Long updateTime) {
417366
return this;
418367
}
419368

420-
/**
421-
* Creates a {@code BlobInfo} object.
422-
*/
423369
@Override
424370
public BlobInfo build() {
425371
checkNotNull(blobId);
@@ -731,7 +677,7 @@ public static Builder builder(BucketInfo bucketInfo, String name) {
731677
* Returns a {@code BlobInfo} builder where blob identity is set using the provided values.
732678
*/
733679
public static Builder builder(String bucket, String name) {
734-
return new BuilderImpl().blobId(BlobId.of(bucket, name));
680+
return builder(BlobId.of(bucket, name));
735681
}
736682

737683
/**
@@ -745,7 +691,7 @@ public static Builder builder(BucketInfo bucketInfo, String name, Long generatio
745691
* Returns a {@code BlobInfo} builder where blob identity is set using the provided values.
746692
*/
747693
public static Builder builder(String bucket, String name, Long generation) {
748-
return new BuilderImpl().blobId(BlobId.of(bucket, name, generation));
694+
return builder(BlobId.of(bucket, name, generation));
749695
}
750696

751697
public static Builder builder(BlobId blobId) {

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static Storage.BucketGetOption[] toGetOptions(BucketInfo bucketInfo,
124124

125125
public static class Builder extends BucketInfo.Builder {
126126
private final Storage storage;
127-
private BucketInfo.BuilderImpl infoBuilder;
127+
private final BucketInfo.BuilderImpl infoBuilder;
128128

129129
Builder(Storage storage) {
130130
this.storage = storage;
@@ -355,8 +355,7 @@ public List<Blob> get(String blobName1, String blobName2, String... blobNames) {
355355
* @throws StorageException upon failure
356356
*/
357357
public Blob create(String blob, byte[] content, String contentType, BlobTargetOption... options) {
358-
BlobInfo blobInfo =
359-
BlobInfo.builder(BlobId.of(name(), blob))
358+
BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob))
360359
.contentType(MoreObjects.firstNonNull(contentType, Storage.DEFAULT_CONTENT_TYPE)).build();
361360
return storage.create(blobInfo, content, options);
362361
}
@@ -376,8 +375,7 @@ public Blob create(String blob, byte[] content, String contentType, BlobTargetOp
376375
*/
377376
public Blob create(String blob, InputStream content, String contentType,
378377
BlobWriteOption... options) {
379-
BlobInfo blobInfo =
380-
BlobInfo.builder(BlobId.of(name(), blob))
378+
BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob))
381379
.contentType(MoreObjects.firstNonNull(contentType, Storage.DEFAULT_CONTENT_TYPE)).build();
382380
return storage.create(blobInfo, content, options);
383381
}
@@ -405,12 +403,12 @@ public int hashCode() {
405403
return Objects.hash(super.hashCode(), options);
406404
}
407405

408-
static Bucket fromPb(Storage storage, com.google.api.services.storage.model.Bucket bucketPb) {
409-
return new Bucket(storage, new BucketInfo.BuilderImpl(BucketInfo.fromPb(bucketPb)));
410-
}
411-
412406
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
413407
in.defaultReadObject();
414408
this.storage = options.service();
415409
}
410+
411+
static Bucket fromPb(Storage storage, com.google.api.services.storage.model.Bucket bucketPb) {
412+
return new Bucket(storage, new BucketInfo.BuilderImpl(BucketInfo.fromPb(bucketPb)));
413+
}
416414
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ void populateCondition(Rule.Condition condition) {
317317
}
318318
}
319319

320-
public static abstract class Builder {
320+
public abstract static class Builder {
321321
/**
322322
* Sets the bucket's name.
323323
*/

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package com.google.gcloud.storage;
1818

19-
import static org.easymock.EasyMock.anyObject;
2019
import static org.easymock.EasyMock.capture;
2120
import static org.easymock.EasyMock.createMock;
2221
import static org.easymock.EasyMock.createStrictMock;
22+
import static org.easymock.EasyMock.eq;
2323
import static org.easymock.EasyMock.expect;
2424
import static org.easymock.EasyMock.replay;
2525
import static org.easymock.EasyMock.verify;
@@ -145,7 +145,7 @@ public void testUpdate() throws Exception {
145145
initializeExpectedBlob(2);
146146
Blob expectedUpdatedBlob = expectedBlob.toBuilder().cacheControl("c").build();
147147
expect(storage.options()).andReturn(mockOptions).times(2);
148-
expect(storage.update(anyObject(Blob.class), new Storage.BlobTargetOption[0]))
148+
expect(storage.update(eq(expectedUpdatedBlob), new Storage.BlobTargetOption[0]))
149149
.andReturn(expectedUpdatedBlob);
150150
replay(storage);
151151
initializeBlob();
@@ -235,7 +235,7 @@ public void testWriter() throws Exception {
235235
initializeExpectedBlob(2);
236236
BlobWriteChannel channel = createMock(BlobWriteChannel.class);
237237
expect(storage.options()).andReturn(mockOptions);
238-
expect(storage.writer(anyObject(Blob.class))).andReturn(channel);
238+
expect(storage.writer(eq(expectedBlob))).andReturn(channel);
239239
replay(storage);
240240
initializeBlob();
241241
assertSame(channel, blob.writer());

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,11 @@ private void initializeExpectedBucket(int optionsCalls) {
6767
storage = createStrictMock(Storage.class);
6868
expectedBucket = new Bucket(serviceMockReturnsOptions, new BucketInfo.BuilderImpl(BUCKET_INFO));
6969
blobResults = ImmutableList.of(
70-
new Blob(
71-
serviceMockReturnsOptions,
70+
new Blob(serviceMockReturnsOptions,
7271
new BlobInfo.BuilderImpl(BlobInfo.builder("b", "n1").build())),
73-
new Blob(
74-
serviceMockReturnsOptions,
72+
new Blob(serviceMockReturnsOptions,
7573
new BlobInfo.BuilderImpl(BlobInfo.builder("b", "n2").build())),
76-
new Blob(
77-
serviceMockReturnsOptions,
74+
new Blob(serviceMockReturnsOptions,
7875
new BlobInfo.BuilderImpl(BlobInfo.builder("b", "n3").build())));
7976
}
8077

0 commit comments

Comments
 (0)