| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -283,7 +283,7 @@ public AuthCredentials authCredentials() { | |||
| 283 | 283 | } | |
| 284 | 284 | ||
| 285 | 285 | public RetryParams retryParams() { | |
| 286 | - return retryParams; | ||
| 286 | + return retryParams != null ? retryParams : RetryParams.noRetries(); | ||
| 287 | 287 | } | |
| 288 | 288 | ||
| 289 | 289 | public ServiceRpcFactory<R, O> serviceRpcFactory() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,7 @@ public class DatastoreServiceOptions extends ServiceOptions<DatastoreRpc, Datast | |||
| 44 | 44 | private final String namespace; | |
| 45 | 45 | private final boolean force; | |
| 46 | 46 | private final boolean normalizeDataset; | |
| 47 | + private transient DatastoreRpc datastoreRpc; | ||
| 47 | 48 | ||
| 48 | 49 | public static class Builder extends | |
| 49 | 50 | ServiceOptions.Builder<DatastoreRpc, DatastoreServiceOptions, Builder> { | |
@@ -178,10 +179,15 @@ public boolean equals(Object obj) { | |||
| 178 | 179 | } | |
| 179 | 180 | ||
| 180 | 181 | DatastoreRpc datastoreRpc() { | |
| 182 | + if (datastoreRpc != null) { | ||
| 183 | + return datastoreRpc; | ||
| 184 | + } | ||
| 181 | 185 | if (serviceRpcFactory() != null) { | |
| 182 | - return serviceRpcFactory().create(this); | ||
| 186 | + datastoreRpc = serviceRpcFactory().create(this); | ||
| 187 | + } else { | ||
| 188 | + datastoreRpc = ServiceRpcProvider.datastore(this); | ||
| 183 | 189 | } | |
| 184 | - return ServiceRpcProvider.datastore(this); | ||
| 190 | + return datastoreRpc; | ||
| 185 | 191 | } | |
| 186 | 192 | ||
| 187 | 193 | public static DatastoreServiceOptions defaultInstance() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,15 +96,15 @@ public boolean equals(Object obj) { | |||
| 96 | 96 | && Objects.equals(toGet, other.toGet); | |
| 97 | 97 | } | |
| 98 | 98 | ||
| 99 | - Map<Blob, Iterable<BlobSourceOption>> toDelete() { | ||
| 99 | + public Map<Blob, Iterable<BlobSourceOption>> toDelete() { | ||
| 100 | 100 | return toDelete; | |
| 101 | 101 | } | |
| 102 | 102 | ||
| 103 | - Map<Blob, Iterable<BlobTargetOption>> toUpdate() { | ||
| 103 | + public Map<Blob, Iterable<BlobTargetOption>> toUpdate() { | ||
| 104 | 104 | return toUpdate; | |
| 105 | 105 | } | |
| 106 | 106 | ||
| 107 | - Map<Blob, Iterable<BlobSourceOption>> toGet() { | ||
| 107 | + public Map<Blob, Iterable<BlobSourceOption>> toGet() { | ||
| 108 | 108 | return toGet; | |
| 109 | 109 | } | |
| 110 | 110 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,12 +43,12 @@ public static class Result<T extends Serializable> implements Serializable { | |||
| 43 | 43 | private final StorageServiceException exception; | |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | - Result(T value) { | ||
| 46 | + public Result(T value) { | ||
| 47 | 47 | this.value = value; | |
| 48 | 48 | this.exception = null; | |
| 49 | 49 | } | |
| 50 | 50 | ||
| 51 | - Result(StorageServiceException exception) { | ||
| 51 | + public Result(StorageServiceException exception) { | ||
| 52 | 52 | this.exception = exception; | |
| 53 | 53 | this.value = null; | |
| 54 | 54 | } | |
@@ -112,7 +112,7 @@ static <T extends Serializable> Result<T> empty() { | |||
| 112 | 112 | } | |
| 113 | 113 | } | |
| 114 | 114 | ||
| 115 | - BatchResponse(List<Result<Boolean>> deleteResult, List<Result<Blob>> updateResult, | ||
| 115 | + public BatchResponse(List<Result<Boolean>> deleteResult, List<Result<Blob>> updateResult, | ||
| 116 | 116 | List<Result<Blob>> getResult) { | |
| 117 | 117 | this.deleteResult = ImmutableList.copyOf(deleteResult); | |
| 118 | 118 | this.updateResult = ImmutableList.copyOf(updateResult); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -103,6 +103,23 @@ public Type type() { | |||
| 103 | 103 | return type; | |
| 104 | 104 | } | |
| 105 | 105 | ||
| 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 | + | ||
| 106 | 123 | Rule toPb() { | |
| 107 | 124 | Rule rule = new Rule(); | |
| 108 | 125 | rule.setAction(new Rule.Action().setType(SUPPORTED_ACTION)); | |
@@ -114,7 +131,7 @@ Rule toPb() { | |||
| 114 | 131 | ||
| 115 | 132 | abstract void populateCondition(Rule.Condition condition); | |
| 116 | 133 | ||
| 117 | - private static DeleteRule fromPb(Rule rule) { | ||
| 134 | + static DeleteRule fromPb(Rule rule) { | ||
| 118 | 135 | if (rule.getAction() != null && SUPPORTED_ACTION.endsWith(rule.getAction().getType())) { | |
| 119 | 136 | Rule.Condition condition = rule.getCondition(); | |
| 120 | 137 | Integer age = condition.getAge(); | |
@@ -346,6 +363,23 @@ public static Location of(String value) { | |||
| 346 | 363 | return option == null ? new Location(value) : option.location; | |
| 347 | 364 | } | |
| 348 | 365 | ||
| 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 | + | ||
| 349 | 383 | @Override | |
| 350 | 384 | public String toString() { | |
| 351 | 385 | return value(); | |
@@ -412,7 +446,7 @@ public Builder notFoundPage(String notFoundPage) { | |||
| 412 | 446 | return this; | |
| 413 | 447 | } | |
| 414 | 448 | ||
| 415 | - public Builder deleteRules(Iterable<DeleteRule> rules) { | ||
| 449 | + public Builder deleteRules(Iterable<? extends DeleteRule> rules) { | ||
| 416 | 450 | this.deleteRules = ImmutableList.copyOf(rules); | |
| 417 | 451 | return this; | |
| 418 | 452 | } | |
@@ -490,7 +524,7 @@ public String name() { | |||
| 490 | 524 | return name; | |
| 491 | 525 | } | |
| 492 | 526 | ||
| 493 | - public Entity Owner() { | ||
| 527 | + public Entity owner() { | ||
| 494 | 528 | return owner; | |
| 495 | 529 | } | |
| 496 | 530 | ||
@@ -510,7 +544,7 @@ public String notFoundPage() { | |||
| 510 | 544 | return notFoundPage; | |
| 511 | 545 | } | |
| 512 | 546 | ||
| 513 | - public List<DeleteRule> deleteRules() { | ||
| 547 | + public List<? extends DeleteRule> deleteRules() { | ||
| 514 | 548 | return deleteRules; | |
| 515 | 549 | } | |
| 516 | 550 | ||
@@ -652,6 +686,7 @@ public Rule apply(DeleteRule deleteRule) { | |||
| 652 | 686 | return deleteRule.toPb(); | |
| 653 | 687 | } | |
| 654 | 688 | })); | |
| 689 | + bucketPb.setLifecycle(lifecycle); | ||
| 655 | 690 | } | |
| 656 | 691 | return bucketPb; | |
| 657 | 692 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -130,17 +130,17 @@ public Builder maxAgeSeconds(Integer maxAgeSeconds) { | |||
| 130 | 130 | } | |
| 131 | 131 | ||
| 132 | 132 | public Builder methods(Iterable<Method> methods) { | |
| 133 | - this.methods = ImmutableList.copyOf(methods); | ||
| 133 | + this.methods = methods != null ? ImmutableList.copyOf(methods) : null; | ||
| 134 | 134 | return this; | |
| 135 | 135 | } | |
| 136 | 136 | ||
| 137 | 137 | public Builder origins(Iterable<Origin> origins) { | |
| 138 | - this.origins = ImmutableList.copyOf(origins); | ||
| 138 | + this.origins = origins != null ? ImmutableList.copyOf(origins) : null; | ||
| 139 | 139 | return this; | |
| 140 | 140 | } | |
| 141 | 141 | ||
| 142 | 142 | public Builder responseHeaders(Iterable<String> headers) { | |
| 143 | - this.responseHeaders = ImmutableList.copyOf(headers); | ||
| 143 | + this.responseHeaders = headers != null ? ImmutableList.copyOf(headers) : null; | ||
| 144 | 144 | return this; | |
| 145 | 145 | } | |
| 146 | 146 | ||
@@ -205,25 +205,33 @@ Bucket.Cors toPb() { | |||
| 205 | 205 | Bucket.Cors pb = new Bucket.Cors(); | |
| 206 | 206 | pb.setMaxAgeSeconds(maxAgeSeconds); | |
| 207 | 207 | 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 | + } | ||
| 210 | 214 | return pb; | |
| 211 | 215 | } | |
| 212 | 216 | ||
| 213 | 217 | static Cors fromPb(Bucket.Cors cors) { | |
| 214 | 218 | 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 | + } | ||
| 227 | 235 | builder.responseHeaders(cors.getResponseHeader()); | |
| 228 | 236 | return builder.build(); | |
| 229 | 237 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,16 +31,35 @@ public final class ListResult<T extends Serializable> implements Iterable<T>, Se | |||
| 31 | 31 | ||
| 32 | 32 | private final String cursor; | |
| 33 | 33 | private final Iterable<T> results; | |
| 34 | + private final NextPageFetcher<T> pageFetcher; | ||
| 34 | 35 | ||
| 35 | - ListResult(String cursor, Iterable<T> results) { | ||
| 36 | + interface NextPageFetcher<T extends Serializable> extends Serializable { | ||
| 37 | + ListResult<T> nextPage(); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public ListResult(NextPageFetcher<T> pageFetcher, String cursor, Iterable<T> results) { | ||
| 41 | + this.pageFetcher = pageFetcher; | ||
| 36 | 42 | this.cursor = cursor; | |
| 37 | 43 | this.results = results; | |
| 38 | 44 | } | |
| 39 | 45 | ||
| 46 | + /** | ||
| 47 | + * Returns the cursor for the nextPage or {@code null} if no more results. | ||
| 48 | + */ | ||
| 40 | 49 | public String nextPageCursor() { | |
| 41 | 50 | return cursor; | |
| 42 | 51 | } | |
| 43 | 52 | ||
| 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 | + | ||
| 44 | 63 | @Override | |
| 45 | 64 | public Iterator<T> iterator() { | |
| 46 | 65 | return results == null ? Collections.<T>emptyIterator() : results.iterator(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments