Skip to content

Commit

Permalink
Merge pull request #86 from aozarov/master
Browse files Browse the repository at this point in the history
rename Bucket to BucketInfo and Blob to BlobInfo
  • Loading branch information
ludoch committed May 29, 2015
2 parents 0ad1cbd + f85b3d6 commit 857077c
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 339 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,39 @@ public final class BatchRequest implements Serializable {

private static final long serialVersionUID = -1527992265939800345L;

private final Map<Blob, Iterable<BlobSourceOption>> toDelete;
private final Map<Blob, Iterable<BlobTargetOption>> toUpdate;
private final Map<Blob, Iterable<BlobSourceOption>> toGet;
private final Map<BlobInfo, Iterable<BlobSourceOption>> toDelete;
private final Map<BlobInfo, Iterable<BlobTargetOption>> toUpdate;
private final Map<BlobInfo, Iterable<BlobSourceOption>> toGet;

public static class Builder {

private Map<Blob, Iterable<BlobSourceOption>> toDelete = new LinkedHashMap<>();
private Map<Blob, Iterable<BlobTargetOption>> toUpdate = new LinkedHashMap<>();
private Map<Blob, Iterable<BlobSourceOption>> toGet = new LinkedHashMap<>();
private Map<BlobInfo, Iterable<BlobSourceOption>> toDelete = new LinkedHashMap<>();
private Map<BlobInfo, Iterable<BlobTargetOption>> toUpdate = new LinkedHashMap<>();
private Map<BlobInfo, Iterable<BlobSourceOption>> toGet = new LinkedHashMap<>();

private Builder() {}

/**
* Delete the given blob.
*/
public Builder delete(String bucket, String blob, BlobSourceOption... options) {
toDelete.put(Blob.of(bucket, blob), Lists.newArrayList(options));
toDelete.put(BlobInfo.of(bucket, blob), Lists.newArrayList(options));
return this;
}

/**
* Update the given blob.
*/
public Builder update(Blob blob, BlobTargetOption... options) {
toUpdate.put(blob, Lists.newArrayList(options));
public Builder update(BlobInfo blobInfo, BlobTargetOption... options) {
toUpdate.put(blobInfo, Lists.newArrayList(options));
return this;
}

/**
* Retrieve metadata for the given blob.
*/
public Builder get(String bucket, String blob, BlobSourceOption... options) {
toGet.put(Blob.of(bucket, blob), Lists.newArrayList(options));
toGet.put(BlobInfo.of(bucket, blob), Lists.newArrayList(options));
return this;
}

Expand Down Expand Up @@ -96,15 +96,15 @@ public boolean equals(Object obj) {
&& Objects.equals(toGet, other.toGet);
}

public Map<Blob, Iterable<BlobSourceOption>> toDelete() {
public Map<BlobInfo, Iterable<BlobSourceOption>> toDelete() {
return toDelete;
}

public Map<Blob, Iterable<BlobTargetOption>> toUpdate() {
public Map<BlobInfo, Iterable<BlobTargetOption>> toUpdate() {
return toUpdate;
}

public Map<Blob, Iterable<BlobSourceOption>> toGet() {
public Map<BlobInfo, Iterable<BlobSourceOption>> toGet() {
return toGet;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public final class BatchResponse implements Serializable {
private static final long serialVersionUID = 1057416839397037706L;

private final List<Result<Boolean>> deleteResult;
private final List<Result<Blob>> updateResult;
private final List<Result<Blob>> getResult;
private final List<Result<BlobInfo>> updateResult;
private final List<Result<BlobInfo>> getResult;

public static class Result<T extends Serializable> implements Serializable {

Expand Down Expand Up @@ -112,8 +112,8 @@ static <T extends Serializable> Result<T> empty() {
}
}

public BatchResponse(List<Result<Boolean>> deleteResult, List<Result<Blob>> updateResult,
List<Result<Blob>> getResult) {
public BatchResponse(List<Result<Boolean>> deleteResult, List<Result<BlobInfo>> updateResult,
List<Result<BlobInfo>> getResult) {
this.deleteResult = ImmutableList.copyOf(deleteResult);
this.updateResult = ImmutableList.copyOf(updateResult);
this.getResult = ImmutableList.copyOf(getResult);
Expand Down Expand Up @@ -145,14 +145,14 @@ public List<Result<Boolean>> deletes() {
/**
* Returns the results for the update operations using the request order.
*/
public List<Result<Blob>> updates() {
public List<Result<BlobInfo>> updates() {
return updateResult;
}

/**
* Returns the results for the get operations using the request order.
*/
public List<Result<Blob>> gets() {
public List<Result<BlobInfo>> gets() {
return getResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,25 @@
*
* @see <a href="https://cloud.google.com/storage/docs/concepts-techniques#concepts">Concepts and Terminology</a>
*/
public final class Blob implements Serializable {
public final class BlobInfo implements Serializable {

private static final long serialVersionUID = 2228487739943277159L;

static final Function<StorageObject, Blob> FROM_PB_FUNCTION =
new Function<StorageObject, Blob>() {
static final Function<StorageObject, BlobInfo> FROM_PB_FUNCTION =
new Function<StorageObject, BlobInfo>() {
@Override
public Blob apply(StorageObject pb) {
return Blob.fromPb(pb);
public BlobInfo apply(StorageObject pb) {
return BlobInfo.fromPb(pb);
}
};

static final Function<Blob, StorageObject> TO_PB_FUNCTION = new Function<Blob, StorageObject>() {
@Override
public StorageObject apply(Blob blob) {
return blob.toPb();
}
};
static final Function<BlobInfo, StorageObject> TO_PB_FUNCTION =
new Function<BlobInfo, StorageObject>() {
@Override
public StorageObject apply(BlobInfo blobInfo) {
return blobInfo.toPb();
}
};

private final String bucket;
private final String id;
Expand Down Expand Up @@ -220,14 +221,14 @@ Builder updateTime(Long updateTime) {
return this;
}

public Blob build() {
public BlobInfo build() {
checkNotNull(bucket);
checkNotNull(name);
return new Blob(this);
return new BlobInfo(this);
}
}

private Blob(Builder builder) {
private BlobInfo(Builder builder) {
bucket = builder.bucket;
name = builder.name;
id = builder.id;
Expand Down Expand Up @@ -377,12 +378,12 @@ public String toString() {
.toString();
}

public static Blob of(String bucket, String name) {
public static BlobInfo of(String bucket, String name) {
return builder(bucket, name).build();
}

public static Builder builder(Bucket bucket, String name) {
return builder(bucket.name(), name);
public static Builder builder(BucketInfo bucketInfo, String name) {
return builder(bucketInfo.name(), name);
}

public static Builder builder(String bucket, String name) {
Expand All @@ -396,10 +397,10 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Blob)) {
if (!(obj instanceof BlobInfo)) {
return false;
}
return Objects.equals(toPb(), ((Blob) obj).toPb());
return Objects.equals(toPb(), ((BlobInfo) obj).toPb());
}

StorageObject toPb() {
Expand Down Expand Up @@ -444,7 +445,7 @@ public ObjectAccessControl apply(Acl acl) {
return storageObject;
}

static Blob fromPb(StorageObject storageObject) {
static BlobInfo fromPb(StorageObject storageObject) {
Builder builder = new Builder()
.bucket(storageObject.getBucket())
.cacheControl(storageObject.getCacheControl())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BlobReadChannelImpl implements BlobReadChannel {
private static final long serialVersionUID = 4821762590742862669L;

private final StorageOptions serviceOptions;
private final Blob blob;
private final BlobInfo blobInfo;
private final Map<StorageRpc.Option, ?> requestOptions;
private int position;
private boolean isOpen;
Expand All @@ -49,10 +49,10 @@ class BlobReadChannelImpl implements BlobReadChannel {
private transient int bufferPos;
private transient byte[] buffer;

BlobReadChannelImpl(StorageOptions serviceOptions, Blob blob,
BlobReadChannelImpl(StorageOptions serviceOptions, BlobInfo blobInfo,
Map<StorageRpc.Option, ?> requestOptions) {
this.serviceOptions = serviceOptions;
this.blob = blob;
this.blobInfo = blobInfo;
this.requestOptions = requestOptions;
isOpen = true;
initTransients();
Expand All @@ -75,7 +75,7 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE

private void initTransients() {
storageRpc = serviceOptions.storageRpc();
storageObject = blob.toPb();
storageObject = blobInfo.toPb();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BlobWriterChannelImpl implements BlobWriteChannel {
private static final int DEFAULT_CHUNK_SIZE = 8 * MIN_CHUNK_SIZE;

private final StorageOptions options;
private final Blob blob;
private final BlobInfo blobInfo;
private final String uploadId;
private int position;
private byte[] buffer = new byte[0];
Expand All @@ -50,10 +50,10 @@ class BlobWriterChannelImpl implements BlobWriteChannel {
private transient StorageRpc storageRpc;
private transient StorageObject storageObject;

public BlobWriterChannelImpl(StorageOptions options, Blob blob,
public BlobWriterChannelImpl(StorageOptions options, BlobInfo blobInfo,
Map<StorageRpc.Option, ?> optionsMap) {
this.options = options;
this.blob = blob;
this.blobInfo = blobInfo;
initTransients();
uploadId = options.storageRpc().open(storageObject, optionsMap);
}
Expand Down Expand Up @@ -91,7 +91,7 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE

private void initTransients() {
storageRpc = options.storageRpc();
storageObject = blob.toPb();
storageObject = blobInfo.toPb();
}

private void validateOpen() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*
* @see <a href="https://cloud.google.com/storage/docs/concepts-techniques#concepts">Concepts and Terminology</a>
*/
public final class Bucket implements Serializable {
public final class BucketInfo implements Serializable {

private static final long serialVersionUID = -3946094202176916586L;

Expand All @@ -69,19 +69,19 @@ public final class Bucket implements Serializable {
private final Location location;
private final StorageClass storageClass;

static final Function<com.google.api.services.storage.model.Bucket, Bucket> FROM_PB_FUNCTION =
new Function<com.google.api.services.storage.model.Bucket, Bucket>() {
static final Function<com.google.api.services.storage.model.Bucket, BucketInfo> FROM_PB_FUNCTION =
new Function<com.google.api.services.storage.model.Bucket, BucketInfo>() {
@Override
public Bucket apply(com.google.api.services.storage.model.Bucket pb) {
return Bucket.fromPb(pb);
public BucketInfo apply(com.google.api.services.storage.model.Bucket pb) {
return BucketInfo.fromPb(pb);
}
};

static final Function<Bucket, com.google.api.services.storage.model.Bucket> TO_PB_FUNCTION =
new Function<Bucket, com.google.api.services.storage.model.Bucket>() {
static final Function<BucketInfo, com.google.api.services.storage.model.Bucket> TO_PB_FUNCTION =
new Function<BucketInfo, com.google.api.services.storage.model.Bucket>() {
@Override
public com.google.api.services.storage.model.Bucket apply(Bucket bucket) {
return bucket.toPb();
public com.google.api.services.storage.model.Bucket apply(BucketInfo bucketInfo) {
return bucketInfo.toPb();
}
};

Expand Down Expand Up @@ -491,13 +491,13 @@ public Builder defaultAcl(Iterable<Acl> acl) {
return this;
}

public Bucket build() {
public BucketInfo build() {
checkNotNull(name);
return new Bucket(this);
return new BucketInfo(this);
}
}

private Bucket(Builder builder) {
private BucketInfo(Builder builder) {
id = builder.id;
name = builder.name;
etag = builder.etag;
Expand Down Expand Up @@ -607,10 +607,10 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Bucket)) {
if (!(obj instanceof BucketInfo)) {
return false;
}
return Objects.equals(toPb(), ((Bucket) obj).toPb());
return Objects.equals(toPb(), ((BucketInfo) obj).toPb());
}

@Override
Expand All @@ -620,7 +620,7 @@ public String toString() {
.toString();
}

public static Bucket of(String name) {
public static BucketInfo of(String name) {
return builder(name).build();
}

Expand Down Expand Up @@ -691,7 +691,7 @@ public Rule apply(DeleteRule deleteRule) {
return bucketPb;
}

static Bucket fromPb(com.google.api.services.storage.model.Bucket bucketPb) {
static BucketInfo fromPb(com.google.api.services.storage.model.Bucket bucketPb) {
Builder builder = new Builder()
.name(bucketPb.getName())
.id(bucketPb.getId())
Expand Down
Loading

0 comments on commit 857077c

Please sign in to comment.