1616
1717package com .google .gcloud .storage ;
1818
19+ import static com .google .api .client .repackaged .com .google .common .base .Preconditions .checkNotNull ;
20+
1921import com .google .api .services .storage .model .Bucket ;
2022import com .google .common .base .MoreObjects ;
2123import com .google .common .collect .ImmutableList ;
@@ -35,8 +37,8 @@ public final class BucketInfo implements Serializable {
3537 private final Cors cors ;
3638 private final ImmutableList <Acl > acl ;
3739 private final ImmutableList <Acl > defaultAcl ;
38- private final String location ;
39- private final String storageClass ;
40+ private final Location location ;
41+ private final StorageClass storageClass ;
4042
4143
4244 public static final class StorageClass implements Serializable {
@@ -45,43 +47,84 @@ public static final class StorageClass implements Serializable {
4547
4648 private final String value ;
4749
48- public enum Type {
50+ public enum Options {
4951 DURABLE_REDUCED_AVAILABILITY ,
50- STANDARD ,
51- OTHER
52- }
52+ STANDARD ;
5353
54- private StorageClass (Type type ) {
55- value = type .name ();
54+ private final StorageClass storageClass ;
55+
56+ Options () {
57+ storageClass = new StorageClass (name ());
58+ }
5659 }
5760
5861 private StorageClass (String value ) {
59- this .value = value ;
62+ this .value = checkNotNull ( value ) ;
6063 }
6164
6265 public static StorageClass standard () {
63- return new StorageClass ( Type .STANDARD ) ;
66+ return Options .STANDARD . storageClass ;
6467 }
6568
6669 public static StorageClass durableReducedAvailability () {
67- return new StorageClass ( Type .DURABLE_REDUCED_AVAILABILITY ) ;
70+ return Options .DURABLE_REDUCED_AVAILABILITY . storageClass ;
6871 }
6972
7073 public static StorageClass other (String other ) {
7174 return new StorageClass (other );
7275 }
76+
77+ public String value () {
78+ return value ;
79+ }
7380 }
7481
75- public enum Location {
76- US , EU , ASIA
82+ public static final class Location implements Serializable {
83+
84+ private static final long serialVersionUID = 9073107666838637662L ;
85+ private final String value ;
86+
87+ public enum Options {
88+ US , EU , ASIA ;
89+
90+ private final Location location ;
91+
92+ Options () {
93+ location = new Location (name ());
94+ }
95+ }
96+
97+ private Location (String value ) {
98+ this .value = checkNotNull (value );
99+ }
100+
101+ public static Location us () {
102+ return Options .US .location ;
103+ }
104+
105+ public static Location eu () {
106+ return Options .EU .location ;
107+ }
108+
109+ public static Location asia () {
110+ return Options .ASIA .location ;
111+ }
112+
113+ public static Location other (String other ) {
114+ return new Location (other );
115+ }
116+
117+ public String value () {
118+ return value ;
119+ }
77120 }
78121
79122 public final static class Builder {
80123
81124 private final String id ;
82125 private final String name ;
83- private String storageClass ;
84- private String location ;
126+ private StorageClass storageClass ;
127+ private Location location ;
85128 private String etag ;
86129 private Long createTime ;
87130 private Long metageneration ;
@@ -95,19 +138,11 @@ public final static class Builder {
95138 }
96139
97140 public Builder storageClass (StorageClass storageClass ) {
98- return storageClass (storageClass .name ());
99- }
100-
101- Builder storageClass (String storageClass ) {
102141 this .storageClass = storageClass ;
103142 return this ;
104143 }
105144
106145 public Builder location (Location location ) {
107- return location (location .name ());
108- }
109-
110- Builder location (String location ) {
111146 this .location = location ;
112147 return this ;
113148 }
@@ -180,11 +215,11 @@ public long metageneration() {
180215 return metageneration ;
181216 }
182217
183- public String lLocation () {
218+ public Location location () {
184219 return location ;
185220 }
186221
187- public String storageClass () {
222+ public StorageClass storageClass () {
188223 return storageClass ;
189224 }
190225
@@ -216,17 +251,19 @@ void fromPb(Bucket bucket) {
216251 Builder builder = new Builder (bucket .getId (), bucket .getName ())
217252 .createTime (bucket .getTimeCreated ().getValue ())
218253 .etag (bucket .getEtag ())
219- .metageneration (bucket .getMetageneration ())
220- .location (bucket .getLocation ())
221- .storageClass (bucket .getStorageClass ());
254+ .metageneration (bucket .getMetageneration ());
255+ // .location(bucket.getLocation())
256+ // .storageClass(bucket.getStorageClass());
222257
258+ /*
223259 cors = builder.cors;
224260 acl = ImmutableList.copyOf(builder.acl);
225261 defaultAcl = ImmutableList.copyOf(builder.defaultAcl);
226-
262+ */
227263
228264 }
229265
266+ /*
230267 Bucket toPb() {
231268 id = builder.id;
232269 name = builder.name;
@@ -238,5 +275,5 @@ Bucket toPb() {
238275 cors = builder.cors;
239276 acl = ImmutableList.copyOf(builder.acl);
240277 defaultAcl = ImmutableList.copyOf(builder.defaultAcl);
241- }
278+ }*/
242279}
0 commit comments