From d4faad32326b9f9043bfc9f405fc00ef4e77690e Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 1 Apr 2016 16:14:08 +0200 Subject: [PATCH] Rename id to generatedId for Storage resources --- .../java/com/google/gcloud/storage/Blob.java | 4 +-- .../com/google/gcloud/storage/BlobInfo.java | 26 +++++++++---------- .../com/google/gcloud/storage/Bucket.java | 4 +-- .../com/google/gcloud/storage/BucketInfo.java | 26 +++++++++---------- .../google/gcloud/storage/BlobInfoTest.java | 12 ++++----- .../com/google/gcloud/storage/BlobTest.java | 10 +++---- .../google/gcloud/storage/BucketInfoTest.java | 14 +++++----- .../com/google/gcloud/storage/BucketTest.java | 8 +++--- .../gcloud/storage/it/ITStorageTest.java | 4 +-- 9 files changed, 54 insertions(+), 54 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index b6f668dada82..9bd9902fee56 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -178,8 +178,8 @@ public Builder blobId(BlobId blobId) { } @Override - Builder id(String id) { - infoBuilder.id(id); + Builder generatedId(String generatedId) { + infoBuilder.generatedId(generatedId); return this; } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java index cf509c8f0961..42a2e282b002 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java @@ -57,9 +57,9 @@ public StorageObject apply(BlobInfo blobInfo) { } }; - private static final long serialVersionUID = 2228487739943277159L; + private static final long serialVersionUID = -5625857076205028976L; private final BlobId blobId; - private final String id; + private final String generatedId; private final String selfLink; private final String cacheControl; private final List acl; @@ -101,7 +101,7 @@ public abstract static class Builder { */ public abstract Builder blobId(BlobId blobId); - abstract Builder id(String id); + abstract Builder generatedId(String generatedId); /** * Sets the blob's data content type. @@ -199,7 +199,7 @@ public abstract static class Builder { static final class BuilderImpl extends Builder { private BlobId blobId; - private String id; + private String generatedId; private String contentType; private String contentEncoding; private String contentDisposition; @@ -226,7 +226,7 @@ static final class BuilderImpl extends Builder { BuilderImpl(BlobInfo blobInfo) { blobId = blobInfo.blobId; - id = blobInfo.id; + generatedId = blobInfo.generatedId; cacheControl = blobInfo.cacheControl; contentEncoding = blobInfo.contentEncoding; contentType = blobInfo.contentType; @@ -255,8 +255,8 @@ public Builder blobId(BlobId blobId) { } @Override - Builder id(String id) { - this.id = id; + Builder generatedId(String generatedId) { + this.generatedId = generatedId; return this; } @@ -384,7 +384,7 @@ public BlobInfo build() { BlobInfo(BuilderImpl builder) { blobId = builder.blobId; - id = builder.id; + generatedId = builder.generatedId; cacheControl = builder.cacheControl; contentEncoding = builder.contentEncoding; contentType = builder.contentType; @@ -421,10 +421,10 @@ public String bucket() { } /** - * Returns the blob's id. + * Returns the service-generated for the blob. */ - public String id() { - return id; + public String generatedId() { + return generatedId; } /** @@ -684,7 +684,7 @@ public ObjectAccessControl apply(Acl acl) { storageObject.setComponentCount(componentCount); storageObject.setContentLanguage(contentLanguage); storageObject.setEtag(etag); - storageObject.setId(id); + storageObject.setId(generatedId); storageObject.setSelfLink(selfLink); return storageObject; } @@ -757,7 +757,7 @@ static BlobInfo fromPb(StorageObject storageObject) { builder.etag(storageObject.getEtag()); } if (storageObject.getId() != null) { - builder.id(storageObject.getId()); + builder.generatedId(storageObject.getId()); } if (storageObject.getSelfLink() != null) { builder.selfLink(storageObject.getSelfLink()); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java index e44bd60d785c..cb2058a9e7ab 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java @@ -427,8 +427,8 @@ public Builder name(String name) { } @Override - Builder id(String id) { - infoBuilder.id(id); + Builder generatedId(String generatedId) { + infoBuilder.generatedId(generatedId); return this; } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java index a1de1a07e03e..a893e45c5c86 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java @@ -64,8 +64,8 @@ public com.google.api.services.storage.model.Bucket apply(BucketInfo bucketInfo) return bucketInfo.toPb(); } }; - private static final long serialVersionUID = -3946094202176916586L; - private final String id; + private static final long serialVersionUID = -4712013629621638459L; + private final String generatedId; private final String name; private final Acl.Entity owner; private final String selfLink; @@ -326,7 +326,7 @@ public abstract static class Builder { */ public abstract Builder name(String name); - abstract Builder id(String id); + abstract Builder generatedId(String generatedId); abstract Builder owner(Acl.Entity owner); @@ -411,7 +411,7 @@ public abstract static class Builder { static final class BuilderImpl extends Builder { - private String id; + private String generatedId; private String name; private Acl.Entity owner; private String selfLink; @@ -433,7 +433,7 @@ static final class BuilderImpl extends Builder { } BuilderImpl(BucketInfo bucketInfo) { - id = bucketInfo.id; + generatedId = bucketInfo.generatedId; name = bucketInfo.name; etag = bucketInfo.etag; createTime = bucketInfo.createTime; @@ -458,8 +458,8 @@ public Builder name(String name) { } @Override - Builder id(String id) { - this.id = id; + Builder generatedId(String generatedId) { + this.generatedId = generatedId; return this; } @@ -555,7 +555,7 @@ public BucketInfo build() { } BucketInfo(BuilderImpl builder) { - id = builder.id; + generatedId = builder.generatedId; name = builder.name; etag = builder.etag; createTime = builder.createTime; @@ -574,10 +574,10 @@ public BucketInfo build() { } /** - * Returns the bucket's id. + * Returns the service-generated id for the bucket. */ - public String id() { - return id; + public String generatedId() { + return generatedId; } /** @@ -733,7 +733,7 @@ public String toString() { com.google.api.services.storage.model.Bucket toPb() { com.google.api.services.storage.model.Bucket bucketPb = new com.google.api.services.storage.model.Bucket(); - bucketPb.setId(id); + bucketPb.setId(generatedId); bucketPb.setName(name); bucketPb.setEtag(etag); if (createTime != null) { @@ -810,7 +810,7 @@ public static Builder builder(String name) { static BucketInfo fromPb(com.google.api.services.storage.model.Bucket bucketPb) { Builder builder = new BuilderImpl(bucketPb.getName()); if (bucketPb.getId() != null) { - builder.id(bucketPb.getId()); + builder.generatedId(bucketPb.getId()); } if (bucketPb.getEtag() != null) { builder.etag(bucketPb.getEtag()); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobInfoTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobInfoTest.java index 029181c6c07b..db9dddaa864e 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobInfoTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobInfoTest.java @@ -51,7 +51,7 @@ public class BlobInfoTest { private static final Long DELETE_TIME = System.currentTimeMillis(); private static final String ETAG = "0xFF00"; private static final Long GENERATION = 1L; - private static final String ID = "B/N:1"; + private static final String GENERATED_ID = "B/N:1"; private static final String MD5 = "0xFF00"; private static final String MEDIA_LINK = "http://media/b/n"; private static final Map METADATA = ImmutableMap.of("n1", "v1", "n2", "v2"); @@ -71,7 +71,7 @@ public class BlobInfoTest { .crc32c(CRC32) .deleteTime(DELETE_TIME) .etag(ETAG) - .id(ID) + .generatedId(GENERATED_ID) .md5(MD5) .mediaLink(MEDIA_LINK) .metadata(METADATA) @@ -118,7 +118,7 @@ public void testBuilder() { assertEquals(DELETE_TIME, BLOB_INFO.deleteTime()); assertEquals(ETAG, BLOB_INFO.etag()); assertEquals(GENERATION, BLOB_INFO.generation()); - assertEquals(ID, BLOB_INFO.id()); + assertEquals(GENERATED_ID, BLOB_INFO.generatedId()); assertEquals(MD5, BLOB_INFO.md5()); assertEquals(MEDIA_LINK, BLOB_INFO.mediaLink()); assertEquals(METADATA, BLOB_INFO.metadata()); @@ -141,7 +141,7 @@ public void testBuilder() { assertNull(DIRECTORY_INFO.deleteTime()); assertNull(DIRECTORY_INFO.etag()); assertNull(DIRECTORY_INFO.generation()); - assertNull(DIRECTORY_INFO.id()); + assertNull(DIRECTORY_INFO.generatedId()); assertNull(DIRECTORY_INFO.md5()); assertNull(DIRECTORY_INFO.mediaLink()); assertNull(DIRECTORY_INFO.metadata()); @@ -168,7 +168,7 @@ private void compareBlobs(BlobInfo expected, BlobInfo value) { assertEquals(expected.deleteTime(), value.deleteTime()); assertEquals(expected.etag(), value.etag()); assertEquals(expected.generation(), value.generation()); - assertEquals(expected.id(), value.id()); + assertEquals(expected.generatedId(), value.generatedId()); assertEquals(expected.md5(), value.md5()); assertEquals(expected.mediaLink(), value.mediaLink()); assertEquals(expected.metadata(), value.metadata()); @@ -203,7 +203,7 @@ public void testToPbAndFromPb() { assertNull(blobInfo.deleteTime()); assertNull(blobInfo.etag()); assertNull(blobInfo.generation()); - assertNull(blobInfo.id()); + assertNull(blobInfo.generatedId()); assertNull(blobInfo.md5()); assertNull(blobInfo.mediaLink()); assertNull(blobInfo.metadata()); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java index d6c97ca9ca03..c8c5fb5d763c 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java @@ -64,7 +64,7 @@ public class BlobTest { private static final Long DELETE_TIME = System.currentTimeMillis(); private static final String ETAG = "0xFF00"; private static final Long GENERATION = 1L; - private static final String ID = "B/N:1"; + private static final String GENERATED_ID = "B/N:1"; private static final String MD5 = "0xFF00"; private static final String MEDIA_LINK = "http://media/b/n"; private static final Map METADATA = ImmutableMap.of("n1", "v1", "n2", "v2"); @@ -84,7 +84,7 @@ public class BlobTest { .crc32c(CRC32) .deleteTime(DELETE_TIME) .etag(ETAG) - .id(ID) + .generatedId(GENERATED_ID) .md5(MD5) .mediaLink(MEDIA_LINK) .metadata(METADATA) @@ -338,7 +338,7 @@ public void testBuilder() { .crc32c(CRC32) .deleteTime(DELETE_TIME) .etag(ETAG) - .id(ID) + .generatedId(GENERATED_ID) .md5(MD5) .mediaLink(MEDIA_LINK) .metadata(METADATA) @@ -360,7 +360,7 @@ public void testBuilder() { assertEquals(CRC32, blob.crc32c()); assertEquals(DELETE_TIME, blob.deleteTime()); assertEquals(ETAG, blob.etag()); - assertEquals(ID, blob.id()); + assertEquals(GENERATED_ID, blob.generatedId()); assertEquals(MD5, blob.md5()); assertEquals(MEDIA_LINK, blob.mediaLink()); assertEquals(METADATA, blob.metadata()); @@ -387,7 +387,7 @@ public void testBuilder() { assertNull(blob.crc32c()); assertNull(blob.deleteTime()); assertNull(blob.etag()); - assertNull(blob.id()); + assertNull(blob.generatedId()); assertNull(blob.md5()); assertNull(blob.mediaLink()); assertNull(blob.metadata()); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketInfoTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketInfoTest.java index bd6bcdbbcff2..6f9fadfdf7cd 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketInfoTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketInfoTest.java @@ -44,7 +44,7 @@ public class BucketInfoTest { Acl.of(User.ofAllAuthenticatedUsers(), Role.READER), Acl.of(new Project(VIEWERS, "p1"), Role.WRITER)); private static final String ETAG = "0xFF00"; - private static final String ID = "B/N:1"; + private static final String GENERATED_ID = "B/N:1"; private static final Long META_GENERATION = 10L; private static final User OWNER = new User("user@gmail.com"); private static final String SELF_LINK = "http://storage/b/n"; @@ -62,7 +62,7 @@ public class BucketInfoTest { private static final BucketInfo BUCKET_INFO = BucketInfo.builder("b") .acl(ACL) .etag(ETAG) - .id(ID) + .generatedId(GENERATED_ID) .metageneration(META_GENERATION) .owner(OWNER) .selfLink(SELF_LINK) @@ -80,10 +80,10 @@ public class BucketInfoTest { @Test public void testToBuilder() { compareBuckets(BUCKET_INFO, BUCKET_INFO.toBuilder().build()); - BucketInfo bucketInfo = BUCKET_INFO.toBuilder().name("B").id("id").build(); + BucketInfo bucketInfo = BUCKET_INFO.toBuilder().name("B").generatedId("id").build(); assertEquals("B", bucketInfo.name()); - assertEquals("id", bucketInfo.id()); - bucketInfo = bucketInfo.toBuilder().name("b").id(ID).build(); + assertEquals("id", bucketInfo.generatedId()); + bucketInfo = bucketInfo.toBuilder().name("b").generatedId(GENERATED_ID).build(); compareBuckets(BUCKET_INFO, bucketInfo); } @@ -104,7 +104,7 @@ public void testBuilder() { assertEquals("b", BUCKET_INFO.name()); assertEquals(ACL, BUCKET_INFO.acl()); assertEquals(ETAG, BUCKET_INFO.etag()); - assertEquals(ID, BUCKET_INFO.id()); + assertEquals(GENERATED_ID, BUCKET_INFO.generatedId()); assertEquals(META_GENERATION, BUCKET_INFO.metageneration()); assertEquals(OWNER, BUCKET_INFO.owner()); assertEquals(SELF_LINK, BUCKET_INFO.selfLink()); @@ -131,7 +131,7 @@ private void compareBuckets(BucketInfo expected, BucketInfo value) { assertEquals(expected.name(), value.name()); assertEquals(expected.acl(), value.acl()); assertEquals(expected.etag(), value.etag()); - assertEquals(expected.id(), value.id()); + assertEquals(expected.generatedId(), value.generatedId()); assertEquals(expected.metageneration(), value.metageneration()); assertEquals(expected.owner(), value.owner()); assertEquals(expected.selfLink(), value.selfLink()); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java index 53056c39c0dc..30b7416531f3 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java @@ -59,7 +59,7 @@ public class BucketTest { private static final List ACL = ImmutableList.of( Acl.of(User.ofAllAuthenticatedUsers(), READER), Acl.of(new Project(VIEWERS, "p1"), WRITER)); private static final String ETAG = "0xFF00"; - private static final String ID = "B/N:1"; + private static final String GENERATED_ID = "B/N:1"; private static final Long META_GENERATION = 10L; private static final User OWNER = new User("user@gmail.com"); private static final String SELF_LINK = "http://storage/b/n"; @@ -77,7 +77,7 @@ public class BucketTest { private static final BucketInfo FULL_BUCKET_INFO = BucketInfo.builder("b") .acl(ACL) .etag(ETAG) - .id(ID) + .generatedId(GENERATED_ID) .metageneration(META_GENERATION) .owner(OWNER) .selfLink(SELF_LINK) @@ -495,7 +495,7 @@ public void testBuilder() { new Bucket.Builder(new Bucket(storage, new BucketInfo.BuilderImpl(BUCKET_INFO))); Bucket bucket = builder.acl(ACL) .etag(ETAG) - .id(ID) + .generatedId(GENERATED_ID) .metageneration(META_GENERATION) .owner(OWNER) .selfLink(SELF_LINK) @@ -512,7 +512,7 @@ public void testBuilder() { assertEquals("b", bucket.name()); assertEquals(ACL, bucket.acl()); assertEquals(ETAG, bucket.etag()); - assertEquals(ID, bucket.id()); + assertEquals(GENERATED_ID, bucket.generatedId()); assertEquals(META_GENERATION, bucket.metageneration()); assertEquals(OWNER, bucket.owner()); assertEquals(SELF_LINK, bucket.selfLink()); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index 13d768442c34..542cf966d269 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -122,7 +122,7 @@ public void testGetBucketSelectedFields() { Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID)); assertEquals(BUCKET, remoteBucket.name()); assertNull(remoteBucket.createTime()); - assertNotNull(remoteBucket.id()); + assertNotNull(remoteBucket.generatedId()); } @Test @@ -256,7 +256,7 @@ public void testGetBlobAllSelectedFields() { assertEquals(blob.bucket(), remoteBlob.bucket()); assertEquals(blob.name(), remoteBlob.name()); assertEquals(ImmutableMap.of("k", "v"), remoteBlob.metadata()); - assertNotNull(remoteBlob.id()); + assertNotNull(remoteBlob.generatedId()); assertNotNull(remoteBlob.selfLink()); assertTrue(remoteBlob.delete()); }