Skip to content

Commit 27e8d43

Browse files
committed
---
yaml --- r: 6013 b: refs/heads/tswast-patch-1 c: 9b54b49 h: refs/heads/master i: 6011: 012636a
1 parent 07fafb0 commit 27e8d43

39 files changed

Lines changed: 490 additions & 612 deletions

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: fbaf57133e83caaf5e4be2866c8935ffc808390a
60+
refs/heads/tswast-patch-1: 9b54b495a45c620b1a3f364c3a0dc031f1052cea
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/src/main/java/com/google/gcloud/ServiceOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public AuthCredentials authCredentials() {
283283
}
284284

285285
public RetryParams retryParams() {
286-
return retryParams != null ? retryParams : RetryParams.noRetries();
286+
return retryParams;
287287
}
288288

289289
public ServiceRpcFactory<R, O> serviceRpcFactory() {

branches/tswast-patch-1/src/main/java/com/google/gcloud/datastore/DatastoreServiceOptions.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public class DatastoreServiceOptions extends ServiceOptions<DatastoreRpc, Datast
4444
private final String namespace;
4545
private final boolean force;
4646
private final boolean normalizeDataset;
47-
private transient DatastoreRpc datastoreRpc;
4847

4948
public static class Builder extends
5049
ServiceOptions.Builder<DatastoreRpc, DatastoreServiceOptions, Builder> {
@@ -179,15 +178,10 @@ public boolean equals(Object obj) {
179178
}
180179

181180
DatastoreRpc datastoreRpc() {
182-
if (datastoreRpc != null) {
183-
return datastoreRpc;
184-
}
185181
if (serviceRpcFactory() != null) {
186-
datastoreRpc = serviceRpcFactory().create(this);
187-
} else {
188-
datastoreRpc = ServiceRpcProvider.datastore(this);
182+
return serviceRpcFactory().create(this);
189183
}
190-
return datastoreRpc;
184+
return ServiceRpcProvider.datastore(this);
191185
}
192186

193187
public static DatastoreServiceOptions defaultInstance() {

branches/tswast-patch-1/src/main/java/com/google/gcloud/storage/Acl.java

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,16 @@ protected String value() {
6161
}
6262

6363
@Override
64-
public boolean equals(Object o) {
65-
if (this == o) {
66-
return true;
67-
}
68-
if (o == null || getClass() != o.getClass()) {
69-
return false;
70-
}
71-
Entity entity = (Entity) o;
72-
return Objects.equals(type, entity.type) &&
73-
Objects.equals(value, entity.value);
64+
public int hashCode() {
65+
return Objects.hash(type, value);
7466
}
7567

7668
@Override
77-
public int hashCode() {
78-
return Objects.hash(type, value);
69+
public boolean equals(Object obj) {
70+
if (obj == null || !getClass().isAssignableFrom(obj.getClass())) {
71+
return false;
72+
}
73+
return Objects.equals(toPb(), ((Entity)obj).toPb());
7974
}
8075

8176
@Override
@@ -100,9 +95,6 @@ static Entity fromPb(String entity) {
10095
if (entity.startsWith("group-")) {
10196
return new Group(entity.substring(6));
10297
}
103-
if (entity.startsWith("domain-")) {
104-
return new Domain(entity.substring(7));
105-
}
10698
if (entity.startsWith("project-")) {
10799
int idx = entity.indexOf('-', 8);
108100
String team = entity.substring(8, idx);
@@ -186,7 +178,7 @@ enum ProjectRole {
186178
OWNERS, EDITORS, VIEWERS
187179
}
188180

189-
public Project(ProjectRole pRole, String projectId) {
181+
Project(ProjectRole pRole, String projectId) {
190182
super(Type.PROJECT, pRole.name().toLowerCase() + "-" + projectId);
191183
this.pRole = pRole;
192184
this.projectId = projectId;
@@ -228,24 +220,6 @@ public Role role() {
228220
return role;
229221
}
230222

231-
@Override
232-
public int hashCode() {
233-
return Objects.hash(entity, role);
234-
}
235-
236-
@Override
237-
public boolean equals(Object obj) {
238-
if (this == obj) {
239-
return true;
240-
}
241-
if (obj == null || getClass() != obj.getClass()) {
242-
return false;
243-
}
244-
final Acl other = (Acl) obj;
245-
return Objects.equals(this.entity, other.entity)
246-
&& Objects.equals(this.role, other.role);
247-
}
248-
249223
BucketAccessControl toBucketPb() {
250224
BucketAccessControl bucketPb = new BucketAccessControl();
251225
bucketPb.setRole(role().toString());

branches/tswast-patch-1/src/main/java/com/google/gcloud/storage/BatchRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ public boolean equals(Object obj) {
9696
&& Objects.equals(toGet, other.toGet);
9797
}
9898

99-
public Map<Blob, Iterable<BlobSourceOption>> toDelete() {
99+
Map<Blob, Iterable<BlobSourceOption>> toDelete() {
100100
return toDelete;
101101
}
102102

103-
public Map<Blob, Iterable<BlobTargetOption>> toUpdate() {
103+
Map<Blob, Iterable<BlobTargetOption>> toUpdate() {
104104
return toUpdate;
105105
}
106106

107-
public Map<Blob, Iterable<BlobSourceOption>> toGet() {
107+
Map<Blob, Iterable<BlobSourceOption>> toGet() {
108108
return toGet;
109109
}
110110

branches/tswast-patch-1/src/main/java/com/google/gcloud/storage/BatchResponse.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,16 @@ public static class Result<T extends Serializable> implements Serializable {
4343
private final StorageServiceException exception;
4444

4545

46-
public Result(T value) {
46+
Result(T value) {
4747
this.value = value;
4848
this.exception = null;
4949
}
5050

51-
public Result(StorageServiceException exception) {
51+
Result(StorageServiceException exception) {
5252
this.exception = exception;
5353
this.value = null;
5454
}
5555

56-
static <T extends Serializable> Result<T> of(T value) {
57-
return new Result<>(value);
58-
}
59-
6056
/**
6157
* Returns the result.
6258
*
@@ -112,7 +108,7 @@ static <T extends Serializable> Result<T> empty() {
112108
}
113109
}
114110

115-
public BatchResponse(List<Result<Boolean>> deleteResult, List<Result<Blob>> updateResult,
111+
BatchResponse(List<Result<Boolean>> deleteResult, List<Result<Blob>> updateResult,
116112
List<Result<Blob>> getResult) {
117113
this.deleteResult = ImmutableList.copyOf(deleteResult);
118114
this.updateResult = ImmutableList.copyOf(updateResult);

branches/tswast-patch-1/src/main/java/com/google/gcloud/storage/Bucket.java

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ public Type type() {
103103
return type;
104104
}
105105

106+
@Override
107+
public int hashCode() {
108+
return Objects.hash(type);
109+
}
110+
111+
@Override
112+
public boolean equals(Object obj) {
113+
if (this == obj) {
114+
return true;
115+
}
116+
if (obj == null || getClass() != obj.getClass()) {
117+
return false;
118+
}
119+
final DeleteRule other = (DeleteRule) obj;
120+
return Objects.equals(toPb(), other.toPb());
121+
}
122+
106123
Rule toPb() {
107124
Rule rule = new Rule();
108125
rule.setAction(new Rule.Action().setType(SUPPORTED_ACTION));
@@ -114,7 +131,7 @@ Rule toPb() {
114131

115132
abstract void populateCondition(Rule.Condition condition);
116133

117-
private static DeleteRule fromPb(Rule rule) {
134+
static DeleteRule fromPb(Rule rule) {
118135
if (rule.getAction() != null && SUPPORTED_ACTION.endsWith(rule.getAction().getType())) {
119136
Rule.Condition condition = rule.getCondition();
120137
Integer age = condition.getAge();
@@ -346,6 +363,23 @@ public static Location of(String value) {
346363
return option == null ? new Location(value) : option.location;
347364
}
348365

366+
@Override
367+
public int hashCode() {
368+
return Objects.hash(value);
369+
}
370+
371+
@Override
372+
public boolean equals(Object obj) {
373+
if (this == obj) {
374+
return true;
375+
}
376+
if (obj == null || getClass() != obj.getClass()) {
377+
return false;
378+
}
379+
final Location other = (Location) obj;
380+
return Objects.equals(this.value, other.value);
381+
}
382+
349383
@Override
350384
public String toString() {
351385
return value();
@@ -412,7 +446,7 @@ public Builder notFoundPage(String notFoundPage) {
412446
return this;
413447
}
414448

415-
public Builder deleteRules(Iterable<DeleteRule> rules) {
449+
public Builder deleteRules(Iterable<? extends DeleteRule> rules) {
416450
this.deleteRules = ImmutableList.copyOf(rules);
417451
return this;
418452
}
@@ -490,7 +524,7 @@ public String name() {
490524
return name;
491525
}
492526

493-
public Entity Owner() {
527+
public Entity owner() {
494528
return owner;
495529
}
496530

@@ -510,7 +544,7 @@ public String notFoundPage() {
510544
return notFoundPage;
511545
}
512546

513-
public List<DeleteRule> deleteRules() {
547+
public List<? extends DeleteRule> deleteRules() {
514548
return deleteRules;
515549
}
516550

@@ -652,6 +686,7 @@ public Rule apply(DeleteRule deleteRule) {
652686
return deleteRule.toPb();
653687
}
654688
}));
689+
bucketPb.setLifecycle(lifecycle);
655690
}
656691
return bucketPb;
657692
}

branches/tswast-patch-1/src/main/java/com/google/gcloud/storage/Cors.java

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,17 @@ public Builder maxAgeSeconds(Integer maxAgeSeconds) {
130130
}
131131

132132
public Builder methods(Iterable<Method> methods) {
133-
this.methods = ImmutableList.copyOf(methods);
133+
this.methods = methods != null ? ImmutableList.copyOf(methods) : null;
134134
return this;
135135
}
136136

137137
public Builder origins(Iterable<Origin> origins) {
138-
this.origins = ImmutableList.copyOf(origins);
138+
this.origins = origins != null ? ImmutableList.copyOf(origins) : null;
139139
return this;
140140
}
141141

142142
public Builder responseHeaders(Iterable<String> headers) {
143-
this.responseHeaders = ImmutableList.copyOf(headers);
143+
this.responseHeaders = headers != null ? ImmutableList.copyOf(headers) : null;
144144
return this;
145145
}
146146

@@ -205,25 +205,33 @@ Bucket.Cors toPb() {
205205
Bucket.Cors pb = new Bucket.Cors();
206206
pb.setMaxAgeSeconds(maxAgeSeconds);
207207
pb.setResponseHeader(responseHeaders);
208-
pb.setMethod(newArrayList(transform(methods(), Functions.toStringFunction())));
209-
pb.setOrigin(newArrayList(transform(origins(), Functions.toStringFunction())));
208+
if (methods != null) {
209+
pb.setMethod(newArrayList(transform(methods, Functions.toStringFunction())));
210+
}
211+
if (origins != null) {
212+
pb.setOrigin(newArrayList(transform(origins, Functions.toStringFunction())));
213+
}
210214
return pb;
211215
}
212216

213217
static Cors fromPb(Bucket.Cors cors) {
214218
Builder builder = builder().maxAgeSeconds(cors.getMaxAgeSeconds());
215-
builder.methods(transform(cors.getMethod(), new Function<String, Method>() {
216-
@Override
217-
public Method apply(String name) {
218-
return Method.valueOf(name.toUpperCase());
219-
}
220-
}));
221-
builder.origins(transform(cors.getOrigin(), new Function<String, Origin>() {
222-
@Override
223-
public Origin apply(String value) {
224-
return Origin.of(value);
225-
}
226-
}));
219+
if (cors.getMethod() != null) {
220+
builder.methods(transform(cors.getMethod(), new Function<String, Method>() {
221+
@Override
222+
public Method apply(String name) {
223+
return Method.valueOf(name.toUpperCase());
224+
}
225+
}));
226+
}
227+
if (cors.getOrigin() != null) {
228+
builder.origins(transform(cors.getOrigin(), new Function<String, Origin>() {
229+
@Override
230+
public Origin apply(String value) {
231+
return Origin.of(value);
232+
}
233+
}));
234+
}
227235
builder.responseHeaders(cors.getResponseHeader());
228236
return builder.build();
229237
}

branches/tswast-patch-1/src/main/java/com/google/gcloud/storage/ListResult.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
package com.google.gcloud.storage;
1818

19-
2019
import java.io.Serializable;
21-
import java.util.Collections;
2220
import java.util.Iterator;
2321
import java.util.Objects;
2422

@@ -31,38 +29,19 @@ public final class ListResult<T extends Serializable> implements Iterable<T>, Se
3129

3230
private final String cursor;
3331
private final Iterable<T> results;
34-
private final NextPageFetcher<T> pageFetcher;
35-
36-
interface NextPageFetcher<T extends Serializable> extends Serializable {
37-
ListResult<T> nextPage();
38-
}
3932

40-
public ListResult(NextPageFetcher<T> pageFetcher, String cursor, Iterable<T> results) {
41-
this.pageFetcher = pageFetcher;
33+
ListResult(String cursor, Iterable<T> results) {
4234
this.cursor = cursor;
4335
this.results = results;
4436
}
4537

46-
/**
47-
* Returns the cursor for the nextPage or {@code null} if no more results.
48-
*/
4938
public String nextPageCursor() {
5039
return cursor;
5140
}
5241

53-
/**
54-
* Returns the results of the nextPage or {@code null} if no more result.
55-
*/
56-
public ListResult<T> nextPage() {
57-
if (cursor == null || pageFetcher == null) {
58-
return null;
59-
}
60-
return pageFetcher.nextPage();
61-
}
62-
6342
@Override
6443
public Iterator<T> iterator() {
65-
return results == null ? Collections.<T>emptyIterator() : results.iterator();
44+
return results.iterator();
6645
}
6746

6847
@Override

0 commit comments

Comments
 (0)