| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ae7e62e commit 288c993
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -258,7 +258,7 @@ import java.nio.channels.WritableByteChannel; | |||
| 258 | 258 | ||
| 259 | 259 | Storage storage = StorageOptions.defaultInstance().service(); | |
| 260 | 260 | BlobId blobId = BlobId.of("bucket", "blob_name"); | |
| 261 | - Blob blob = storage.get(storage, blobId); | ||
| 261 | + Blob blob = storage.get(blobId); | ||
| 262 | 262 | if (blob == null) { | |
| 263 | 263 | BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build(); | |
| 264 | 264 | storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,6 +38,9 @@ public class Project extends ProjectInfo { | |||
| 38 | 38 | private final ResourceManagerOptions options; | |
| 39 | 39 | private transient ResourceManager resourceManager; | |
| 40 | 40 | ||
| 41 | + /** | ||
| 42 | + * Builder for {@code Project}. | ||
| 43 | + */ | ||
| 41 | 44 | public static class Builder extends ProjectInfo.Builder { | |
| 42 | 45 | private final ResourceManager resourceManager; | |
| 43 | 46 | private final ProjectInfo.BuilderImpl infoBuilder; | |
@@ -127,7 +130,7 @@ public ResourceManager resourceManager() { | |||
| 127 | 130 | } | |
| 128 | 131 | ||
| 129 | 132 | /** | |
| 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 | ||
| 131 | 134 | * exist. | |
| 132 | 135 | * | |
| 133 | 136 | * @return Project containing the project's updated metadata or {@code null} if not found | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -115,6 +115,9 @@ static ResourceId fromPb( | |||
| 115 | 115 | } | |
| 116 | 116 | } | |
| 117 | 117 | ||
| 118 | + /** | ||
| 119 | + * Builder for {@code ProjectInfo}. | ||
| 120 | + */ | ||
| 118 | 121 | public abstract static class Builder { | |
| 119 | 122 | ||
| 120 | 123 | /** | |
@@ -184,7 +187,9 @@ static class BuilderImpl extends Builder { | |||
| 184 | 187 | private Long createTimeMillis; | |
| 185 | 188 | private ResourceId parent; | |
| 186 | 189 | ||
| 187 | - BuilderImpl() {} | ||
| 190 | + BuilderImpl(String projectId) { | ||
| 191 | + this.projectId = projectId; | ||
| 192 | + } | ||
| 188 | 193 | ||
| 189 | 194 | BuilderImpl(ProjectInfo info) { | |
| 190 | 195 | this.name = info.name; | |
@@ -331,7 +336,7 @@ public Long createTimeMillis() { | |||
| 331 | 336 | ||
| 332 | 337 | @Override | |
| 333 | 338 | public boolean equals(Object obj) { | |
| 334 | - return obj.getClass().equals(ProjectInfo.class) | ||
| 339 | + return obj != null && obj.getClass().equals(ProjectInfo.class) | ||
| 335 | 340 | && Objects.equals(toPb(), ((ProjectInfo) obj).toPb()); | |
| 336 | 341 | } | |
| 337 | 342 | ||
@@ -341,7 +346,7 @@ public int hashCode() { | |||
| 341 | 346 | } | |
| 342 | 347 | ||
| 343 | 348 | public static Builder builder(String id) { | |
| 344 | - return new BuilderImpl().projectId(id); | ||
| 349 | + return new BuilderImpl(id); | ||
| 345 | 350 | } | |
| 346 | 351 | ||
| 347 | 352 | public Builder toBuilder() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,9 +87,9 @@ public void testBuilder() { | |||
| 87 | 87 | initializeExpectedProject(4); | |
| 88 | 88 | expect(resourceManager.options()).andReturn(mockOptions).times(4); | |
| 89 | 89 | 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))); | ||
| 91 | 92 | Project project = builder.name(NAME) | |
| 92 | - .projectId(PROJECT_ID) | ||
| 93 | 93 | .labels(LABELS) | |
| 94 | 94 | .projectNumber(PROJECT_NUMBER) | |
| 95 | 95 | .createTimeMillis(CREATE_TIME_MILLIS) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,6 +157,9 @@ static Storage.BlobGetOption[] toGetOptions(BlobInfo blobInfo, BlobSourceOption. | |||
| 157 | 157 | } | |
| 158 | 158 | } | |
| 159 | 159 | ||
| 160 | + /** | ||
| 161 | + * Builder for {@code Blob}. | ||
| 162 | + */ | ||
| 160 | 163 | public static class Builder extends BlobInfo.Builder { | |
| 161 | 164 | ||
| 162 | 165 | private final Storage storage; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -90,6 +90,9 @@ public Set<Entry<K, V>> entrySet() { | |||
| 90 | 90 | } | |
| 91 | 91 | } | |
| 92 | 92 | ||
| 93 | + /** | ||
| 94 | + * Builder for {@code BlobInfo}. | ||
| 95 | + */ | ||
| 93 | 96 | public abstract static class Builder { | |
| 94 | 97 | ||
| 95 | 98 | /** | |
@@ -213,7 +216,9 @@ static final class BuilderImpl extends Builder { | |||
| 213 | 216 | private Long deleteTime; | |
| 214 | 217 | private Long updateTime; | |
| 215 | 218 | ||
| 216 | - BuilderImpl() {} | ||
| 219 | + BuilderImpl(BlobId blobId) { | ||
| 220 | + this.blobId = blobId; | ||
| 221 | + } | ||
| 217 | 222 | ||
| 218 | 223 | BuilderImpl(BlobInfo blobInfo) { | |
| 219 | 224 | blobId = blobInfo.blobId; | |
@@ -609,7 +614,8 @@ public int hashCode() { | |||
| 609 | 614 | ||
| 610 | 615 | @Override | |
| 611 | 616 | 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()); | ||
| 613 | 619 | } | |
| 614 | 620 | ||
| 615 | 621 | StorageObject toPb() { | |
@@ -688,7 +694,7 @@ public static Builder builder(String bucket, String name, Long generation) { | |||
| 688 | 694 | } | |
| 689 | 695 | ||
| 690 | 696 | public static Builder builder(BlobId blobId) { | |
| 691 | - return new BuilderImpl().blobId(blobId); | ||
| 697 | + return new BuilderImpl(blobId); | ||
| 692 | 698 | } | |
| 693 | 699 | ||
| 694 | 700 | static BlobInfo fromPb(StorageObject storageObject) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,6 +48,8 @@ | |||
| 48 | 48 | */ | |
| 49 | 49 | public final class Bucket extends BucketInfo { | |
| 50 | 50 | ||
| 51 | + private static final long serialVersionUID = 8574601739542252586L; | ||
| 52 | + | ||
| 51 | 53 | private final StorageOptions options; | |
| 52 | 54 | private transient Storage storage; | |
| 53 | 55 | ||
@@ -122,6 +124,9 @@ static Storage.BucketGetOption[] toGetOptions(BucketInfo bucketInfo, | |||
| 122 | 124 | } | |
| 123 | 125 | } | |
| 124 | 126 | ||
| 127 | + /** | ||
| 128 | + * Builder for {@code Bucket}. | ||
| 129 | + */ | ||
| 125 | 130 | public static class Builder extends BucketInfo.Builder { | |
| 126 | 131 | private final Storage storage; | |
| 127 | 132 | private final BucketInfo.BuilderImpl infoBuilder; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -317,6 +317,9 @@ void populateCondition(Rule.Condition condition) { | |||
| 317 | 317 | } | |
| 318 | 318 | } | |
| 319 | 319 | ||
| 320 | + /** | ||
| 321 | + * Builder for {@code BucketInfo}. | ||
| 322 | + */ | ||
| 320 | 323 | public abstract static class Builder { | |
| 321 | 324 | /** | |
| 322 | 325 | * Sets the bucket's name. | |
@@ -425,7 +428,9 @@ static final class BuilderImpl extends Builder { | |||
| 425 | 428 | private List<Acl> acl; | |
| 426 | 429 | private List<Acl> defaultAcl; | |
| 427 | 430 | ||
| 428 | - BuilderImpl() {} | ||
| 431 | + BuilderImpl(String name) { | ||
| 432 | + this.name = name; | ||
| 433 | + } | ||
| 429 | 434 | ||
| 430 | 435 | BuilderImpl(BucketInfo bucketInfo) { | |
| 431 | 436 | id = bucketInfo.id; | |
@@ -714,7 +719,7 @@ public int hashCode() { | |||
| 714 | 719 | ||
| 715 | 720 | @Override | |
| 716 | 721 | public boolean equals(Object obj) { | |
| 717 | - return obj.getClass().equals(BucketInfo.class) | ||
| 722 | + return obj != null && obj.getClass().equals(BucketInfo.class) | ||
| 718 | 723 | && Objects.equals(toPb(), ((BucketInfo) obj).toPb()); | |
| 719 | 724 | } | |
| 720 | 725 | ||
@@ -799,11 +804,11 @@ public static BucketInfo of(String name) { | |||
| 799 | 804 | * Returns a {@code BucketInfo} builder where the bucket's name is set to the provided name. | |
| 800 | 805 | */ | |
| 801 | 806 | public static Builder builder(String name) { | |
| 802 | - return new BuilderImpl().name(name); | ||
| 807 | + return new BuilderImpl(name); | ||
| 803 | 808 | } | |
| 804 | 809 | ||
| 805 | 810 | 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()); | ||
| 807 | 812 | if (bucketPb.getId() != null) { | |
| 808 | 813 | builder.id(bucketPb.getId()); | |
| 809 | 814 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1208,7 +1208,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx | |||
| 1208 | 1208 | /** | |
| 1209 | 1209 | * Create a new bucket. | |
| 1210 | 1210 | * | |
| 1211 | - * @return a complete bucket information | ||
| 1211 | + * @return a complete bucket | ||
| 1212 | 1212 | * @throws StorageException upon failure | |
| 1213 | 1213 | */ | |
| 1214 | 1214 | Bucket create(BucketInfo bucketInfo, BucketTargetOption... options); | |
@@ -1479,7 +1479,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx | |||
| 1479 | 1479 | * Gets the requested blobs. A batch request is used to perform this call. | |
| 1480 | 1480 | * | |
| 1481 | 1481 | * @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 | ||
| 1483 | 1483 | * has been denied the corresponding item in the list is {@code null}. | |
| 1484 | 1484 | * @throws StorageException upon failure | |
| 1485 | 1485 | */ | |
@@ -1493,7 +1493,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx | |||
| 1493 | 1493 | * {@link #update(com.google.gcloud.storage.BlobInfo)} for a code example. | |
| 1494 | 1494 | * | |
| 1495 | 1495 | * @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 | ||
| 1497 | 1497 | * has been denied the corresponding item in the list is {@code null}. | |
| 1498 | 1498 | * @throws StorageException upon failure | |
| 1499 | 1499 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -266,7 +266,7 @@ public Bucket apply(com.google.api.services.storage.model.Bucket bucketPb) { | |||
| 266 | 266 | return Bucket.fromPb(serviceOptions.service(), bucketPb); | |
| 267 | 267 | } | |
| 268 | 268 | }); | |
| 269 | - return new PageImpl<Bucket>( | ||
| 269 | + return new PageImpl<>( | ||
| 270 | 270 | new BucketPageFetcher(serviceOptions, cursor, optionsMap), cursor, | |
| 271 | 271 | buckets); | |
| 272 | 272 | } catch (RetryHelperException e) { | |
@@ -294,7 +294,7 @@ public Blob apply(StorageObject storageObject) { | |||
| 294 | 294 | return Blob.fromPb(serviceOptions.service(), storageObject); | |
| 295 | 295 | } | |
| 296 | 296 | }); | |
| 297 | - return new PageImpl<Blob>( | ||
| 297 | + return new PageImpl<>( | ||
| 298 | 298 | new BlobPageFetcher(bucket, serviceOptions, cursor, optionsMap), | |
| 299 | 299 | cursor, | |
| 300 | 300 | blobs); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments