Skip to content

Commit

Permalink
Rename id to generatedId for Storage resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Apr 1, 2016
1 parent 3324808 commit d4faad3
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> acl;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> METADATA = ImmutableMap.of("n1", "v1", "n2", "v2");
Expand All @@ -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)
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> METADATA = ImmutableMap.of("n1", "v1", "n2", "v2");
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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());
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]");
private static final String SELF_LINK = "http://storage/b/n";
Expand All @@ -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)
Expand All @@ -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);
}

Expand All @@ -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());
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class BucketTest {
private static final List<Acl> 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("[email protected]");
private static final String SELF_LINK = "http://storage/b/n";
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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());
Expand Down
Loading

0 comments on commit d4faad3

Please sign in to comment.