Skip to content

Commit ca55908

Browse files
committed
---
yaml --- r: 6145 b: refs/heads/tswast-patch-1 c: c1f018c h: refs/heads/master i: 6143: b81efd6
1 parent 4fe72be commit ca55908

3 files changed

Lines changed: 35 additions & 28 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 44cefb06a9f1a2393f0191fe93e34b9776ced00d
60+
refs/heads/tswast-patch-1: c1f018c35c46b9d9e2416fc0a8c542d972d78518
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobListResult.java

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
package com.google.gcloud.storage;
1818

19+
import static com.google.common.base.Preconditions.checkNotNull;
20+
1921
import java.util.Iterator;
20-
import java.util.LinkedList;
21-
import java.util.List;
2222
import java.util.Objects;
2323

2424
/**
@@ -27,13 +27,35 @@
2727
public class BlobListResult implements ListResult<Blob> {
2828

2929
private final ListResult<BlobInfo> infoList;
30-
private final transient Storage storage;
31-
private transient List<Blob> results;
30+
private final Storage storage;
31+
32+
private class BlobListIterator implements Iterator<Blob> {
33+
34+
private final Iterator<BlobInfo> blobInfoIterator;
35+
36+
public BlobListIterator() {
37+
this.blobInfoIterator = infoList.iterator();
38+
}
39+
40+
@Override
41+
public boolean hasNext() {
42+
return blobInfoIterator.hasNext();
43+
}
44+
45+
@Override
46+
public Blob next() {
47+
return new Blob(storage, blobInfoIterator.next());
48+
}
49+
50+
@Override
51+
public void remove() {
52+
blobInfoIterator.remove();
53+
}
54+
}
3255

3356
public BlobListResult(Storage storage, ListResult<BlobInfo> infoList) {
34-
this.storage = storage;
35-
this.infoList = infoList;
36-
this.results = null;
57+
this.storage = checkNotNull(storage);
58+
this.infoList = checkNotNull(infoList);
3759
}
3860

3961
@Override
@@ -52,13 +74,7 @@ public ListResult<Blob> nextPage() {
5274

5375
@Override
5476
public Iterator<Blob> iterator() {
55-
if (results == null) {
56-
this.results = new LinkedList<>();
57-
for (Iterator<BlobInfo> it = infoList.iterator(); it.hasNext();) {
58-
results.add(new Blob(storage, it.next()));
59-
}
60-
}
61-
return results.iterator();
77+
return new BlobListIterator();
6278
}
6379

6480
@Override

branches/tswast-patch-1/gcloud-java-storage/src/main/java/com/google/gcloud/storage/ListResult.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,19 @@
1616

1717
package com.google.gcloud.storage;
1818

19-
import java.util.Iterator;
20-
2119
/**
2220
* Interface for Google Cloud storage list result.
2321
*/
2422
public interface ListResult<T> extends Iterable<T> {
2523

2624
/**
27-
* Returns the cursor for the nextPage or {@code null} if no more results.
28-
*
29-
* @return the string cursor for next page
25+
* Return the cursor for the nextPage or {@code null} if no more results.
3026
*/
31-
public String nextPageCursor();
27+
String nextPageCursor();
3228

3329
/**
34-
* Returns the results of the nextPage or {@code null} if no more result.
35-
*
36-
* @return the {@code ListResult} object for the next page
30+
* Return the results of the nextPage or {@code null} if no more result.
3731
*/
38-
public ListResult<T> nextPage();
39-
40-
@Override
41-
public Iterator<T> iterator();
32+
ListResult<T> nextPage();
4233

4334
}

0 commit comments

Comments
 (0)