1818
1919import static com .google .common .base .Preconditions .checkArgument ;
2020import static com .google .common .base .Preconditions .checkNotNull ;
21+ import static com .google .gcloud .storage .Bucket .BucketSourceOption .toGetOptions ;
22+ import static com .google .gcloud .storage .Bucket .BucketSourceOption .toSourceOptions ;
2123
2224import com .google .common .base .Function ;
2325import com .google .common .base .MoreObjects ;
3537import java .io .ObjectInputStream ;
3638import java .io .Serializable ;
3739import java .util .ArrayList ;
40+ import java .util .Arrays ;
3841import java .util .Collections ;
3942import java .util .Iterator ;
4043import java .util .List ;
@@ -218,8 +221,11 @@ public BucketInfo info() {
218221 * @return true if this bucket exists, false otherwise
219222 * @throws StorageException upon failure
220223 */
221- public boolean exists () {
222- return storage .get (info .name ()) != null ;
224+ public boolean exists (BucketSourceOption ... options ) {
225+ int length = options .length ;
226+ Storage .BucketGetOption [] getOptions = Arrays .copyOf (toGetOptions (info , options ), length + 1 );
227+ getOptions [length ] = Storage .BucketGetOption .fields ();
228+ return storage .get (info .name (), getOptions ) != null ;
223229 }
224230
225231 /**
@@ -230,8 +236,7 @@ public boolean exists() {
230236 * @throws StorageException upon failure
231237 */
232238 public Bucket reload (BucketSourceOption ... options ) {
233- return new Bucket (storage , storage .get (info .name (),
234- BucketSourceOption .toGetOptions (info , options )));
239+ return new Bucket (storage , storage .get (info .name (), toGetOptions (info , options )));
235240 }
236241
237242 /**
@@ -259,7 +264,7 @@ public Bucket update(BucketInfo bucketInfo, BucketTargetOption... options) {
259264 * @throws StorageException upon failure
260265 */
261266 public boolean delete (BucketSourceOption ... options ) {
262- return storage .delete (info .name (), BucketSourceOption . toSourceOptions (info , options ));
267+ return storage .delete (info .name (), toSourceOptions (info , options ));
263268 }
264269
265270 /**
0 commit comments