Skip to content

Commit 0e2beb1

Browse files
author
Ajay Kannan
committed
Minor fixes
1 parent ae7e62e commit 0e2beb1

File tree

12 files changed

+47
-20
lines changed

12 files changed

+47
-20
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ import java.nio.channels.WritableByteChannel;
258258
259259
Storage storage = StorageOptions.defaultInstance().service();
260260
BlobId blobId = BlobId.of("bucket", "blob_name");
261-
Blob blob = storage.get(storage, blobId);
261+
Blob blob = storage.get(blobId);
262262
if (blob == null) {
263263
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
264264
storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class Project extends ProjectInfo {
3838
private final ResourceManagerOptions options;
3939
private transient ResourceManager resourceManager;
4040

41+
/**
42+
* Builder for {@code Project}.
43+
*/
4144
public static class Builder extends ProjectInfo.Builder {
4245
private final ResourceManager resourceManager;
4346
private final ProjectInfo.BuilderImpl infoBuilder;
@@ -127,7 +130,7 @@ public ResourceManager resourceManager() {
127130
}
128131

129132
/**
130-
* Fetches the current project's latest information. Returns {@code null} if the job does not
133+
* Fetches the project's latest information. Returns {@code null} if the project does not
131134
* exist.
132135
*
133136
* @return Project containing the project's updated metadata or {@code null} if not found

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ static ResourceId fromPb(
115115
}
116116
}
117117

118+
/**
119+
* Builder for {@code ProjectInfo}.
120+
*/
118121
public abstract static class Builder {
119122

120123
/**
@@ -184,7 +187,9 @@ static class BuilderImpl extends Builder {
184187
private Long createTimeMillis;
185188
private ResourceId parent;
186189

187-
BuilderImpl() {}
190+
BuilderImpl(String projectId) {
191+
this.projectId = projectId;
192+
}
188193

189194
BuilderImpl(ProjectInfo info) {
190195
this.name = info.name;
@@ -331,7 +336,7 @@ public Long createTimeMillis() {
331336

332337
@Override
333338
public boolean equals(Object obj) {
334-
return obj.getClass().equals(ProjectInfo.class)
339+
return obj != null && obj.getClass().equals(ProjectInfo.class)
335340
&& Objects.equals(toPb(), ((ProjectInfo) obj).toPb());
336341
}
337342

@@ -341,7 +346,7 @@ public int hashCode() {
341346
}
342347

343348
public static Builder builder(String id) {
344-
return new BuilderImpl().projectId(id);
349+
return new BuilderImpl(id);
345350
}
346351

347352
public Builder toBuilder() {

gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ public void testBuilder() {
8787
initializeExpectedProject(4);
8888
expect(resourceManager.options()).andReturn(mockOptions).times(4);
8989
replay(resourceManager);
90-
Project.Builder builder = new Project.Builder(new Project(resourceManager, new ProjectInfo.BuilderImpl()));
90+
Project.Builder builder =
91+
new Project.Builder(new Project(resourceManager, new ProjectInfo.BuilderImpl(PROJECT_ID)));
9192
Project project = builder.name(NAME)
92-
.projectId(PROJECT_ID)
9393
.labels(LABELS)
9494
.projectNumber(PROJECT_NUMBER)
9595
.createTimeMillis(CREATE_TIME_MILLIS)

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

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ static Storage.BlobGetOption[] toGetOptions(BlobInfo blobInfo, BlobSourceOption.
157157
}
158158
}
159159

160+
/**
161+
* Builder for {@code BlobInfo}.
162+
*/
160163
public static class Builder extends BlobInfo.Builder {
161164

162165
private final Storage storage;

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ public Set<Entry<K, V>> entrySet() {
9090
}
9191
}
9292

93+
/**
94+
* Builder for {@code BlobInfo}.
95+
*/
9396
public abstract static class Builder {
9497

9598
/**
@@ -213,7 +216,9 @@ static final class BuilderImpl extends Builder {
213216
private Long deleteTime;
214217
private Long updateTime;
215218

216-
BuilderImpl() {}
219+
BuilderImpl(BlobId blobId) {
220+
this.blobId = blobId;
221+
}
217222

218223
BuilderImpl(BlobInfo blobInfo) {
219224
blobId = blobInfo.blobId;
@@ -609,7 +614,8 @@ public int hashCode() {
609614

610615
@Override
611616
public boolean equals(Object obj) {
612-
return obj.getClass().equals(BlobInfo.class) && Objects.equals(toPb(), ((BlobInfo) obj).toPb());
617+
return obj != null && obj.getClass().equals(BlobInfo.class)
618+
&& Objects.equals(toPb(), ((BlobInfo) obj).toPb());
613619
}
614620

615621
StorageObject toPb() {
@@ -688,7 +694,7 @@ public static Builder builder(String bucket, String name, Long generation) {
688694
}
689695

690696
public static Builder builder(BlobId blobId) {
691-
return new BuilderImpl().blobId(blobId);
697+
return new BuilderImpl(blobId);
692698
}
693699

694700
static BlobInfo fromPb(StorageObject storageObject) {

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

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
*/
4949
public final class Bucket extends BucketInfo {
5050

51+
private static final long serialVersionUID = 8574601739542252586L;
52+
5153
private final StorageOptions options;
5254
private transient Storage storage;
5355

@@ -122,6 +124,9 @@ static Storage.BucketGetOption[] toGetOptions(BucketInfo bucketInfo,
122124
}
123125
}
124126

127+
/**
128+
* Builder for {@code Bucket}.
129+
*/
125130
public static class Builder extends BucketInfo.Builder {
126131
private final Storage storage;
127132
private final BucketInfo.BuilderImpl infoBuilder;

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

+9-4
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ void populateCondition(Rule.Condition condition) {
317317
}
318318
}
319319

320+
/**
321+
* Builder for {@code BucketInfo}.
322+
*/
320323
public abstract static class Builder {
321324
/**
322325
* Sets the bucket's name.
@@ -425,7 +428,9 @@ static final class BuilderImpl extends Builder {
425428
private List<Acl> acl;
426429
private List<Acl> defaultAcl;
427430

428-
BuilderImpl() {}
431+
BuilderImpl(String name) {
432+
this.name = name;
433+
}
429434

430435
BuilderImpl(BucketInfo bucketInfo) {
431436
id = bucketInfo.id;
@@ -714,7 +719,7 @@ public int hashCode() {
714719

715720
@Override
716721
public boolean equals(Object obj) {
717-
return obj.getClass().equals(BucketInfo.class)
722+
return obj != null && obj.getClass().equals(BucketInfo.class)
718723
&& Objects.equals(toPb(), ((BucketInfo) obj).toPb());
719724
}
720725

@@ -799,11 +804,11 @@ public static BucketInfo of(String name) {
799804
* Returns a {@code BucketInfo} builder where the bucket's name is set to the provided name.
800805
*/
801806
public static Builder builder(String name) {
802-
return new BuilderImpl().name(name);
807+
return new BuilderImpl(name);
803808
}
804809

805810
static BucketInfo fromPb(com.google.api.services.storage.model.Bucket bucketPb) {
806-
Builder builder = new BuilderImpl().name(bucketPb.getName());
811+
Builder builder = new BuilderImpl(bucketPb.getName());
807812
if (bucketPb.getId() != null) {
808813
builder.id(bucketPb.getId());
809814
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx
12081208
/**
12091209
* Create a new bucket.
12101210
*
1211-
* @return a complete bucket information
1211+
* @return a complete bucket
12121212
* @throws StorageException upon failure
12131213
*/
12141214
Bucket create(BucketInfo bucketInfo, BucketTargetOption... options);
@@ -1479,7 +1479,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx
14791479
* Gets the requested blobs. A batch request is used to perform this call.
14801480
*
14811481
* @param blobIds blobs to get
1482-
* @return an immutable list of {@code BlobInfo} objects. If a blob does not exist or access to it
1482+
* @return an immutable list of {@code Blob} objects. If a blob does not exist or access to it
14831483
* has been denied the corresponding item in the list is {@code null}.
14841484
* @throws StorageException upon failure
14851485
*/
@@ -1493,7 +1493,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx
14931493
* {@link #update(com.google.gcloud.storage.BlobInfo)} for a code example.
14941494
*
14951495
* @param blobInfos blobs to update
1496-
* @return an immutable list of {@code BlobInfo} objects. If a blob does not exist or access to it
1496+
* @return an immutable list of {@code Blob} objects. If a blob does not exist or access to it
14971497
* has been denied the corresponding item in the list is {@code null}.
14981498
* @throws StorageException upon failure
14991499
*/

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public Bucket apply(com.google.api.services.storage.model.Bucket bucketPb) {
266266
return Bucket.fromPb(serviceOptions.service(), bucketPb);
267267
}
268268
});
269-
return new PageImpl<Bucket>(
269+
return new PageImpl<>(
270270
new BucketPageFetcher(serviceOptions, cursor, optionsMap), cursor,
271271
buckets);
272272
} catch (RetryHelperException e) {

gcloud-java-storage/src/main/java/com/google/gcloud/storage/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* <pre> {@code
2222
* Storage storage = StorageOptions.defaultInstance().service();
2323
* BlobId blobId = BlobId.of("bucket", "blob_name");
24-
* Blob blob = storage.get(storage, blobId);
24+
* Blob blob = storage.get(blobId);
2525
* if (blob == null) {
2626
* BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
2727
* storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
<plugin>
254254
<groupId>org.eluder.coveralls</groupId>
255255
<artifactId>coveralls-maven-plugin</artifactId>
256-
<version>4.1.0</version>
256+
<version>3.1.0</version>
257257
<configuration>
258258
<coberturaReports>
259259
<coberturaReport>${basedir}/target/coverage.xml</coberturaReport>

0 commit comments

Comments
 (0)