1616
1717package com .google .gcloud .storage ;
1818
19+ import com .google .api .services .storage .model .Bucket ;
20+ import com .google .common .base .MoreObjects ;
21+ import com .google .common .collect .ImmutableList ;
22+
23+ import java .util .List ;
24+
1925public final class BucketInfo {
2026
2127 private final String id ;
2228 private final String name ;
29+ private final String etag ;
2330 private final long createTime ;
2431 private final long metageneration ;
2532 private final Cors cors ;
26- private final Acl acl ;
27- private final Acl defaultAcl ;
33+ private final ImmutableList <Acl > acl ;
34+ private final ImmutableList <Acl > defaultAcl ;
35+ private final Location location ;
36+ private final StorageClass storageClass ;
2837
2938 public enum StorageClass {
3039 DURABLE_REDUCED_AVAILABILITY ,
3140 STANDARD
3241 }
3342
43+ public enum Location {
44+ US , EU , ASIA
45+ }
46+
3447 public final static class Builder {
3548
3649 private final String id ;
3750 private final String name ;
38- private final long createTime ;
39- private final long metageneration ;
51+ private StorageClass storageClass ;
52+ private Location location ;
53+ private String etag ;
54+ private Long createTime ;
55+ private Long metageneration ;
4056 private Cors cors ;
41- private Acl acl ;
42- private Acl defaultAcl ;
57+ private Iterable < Acl > acl ;
58+ private Iterable < Acl > defaultAcl ;
4359
44- Builder (String id , String name , long createTime , long metageneration ) {
60+ Builder (String id , String name ) {
4561 this .id = id ;
4662 this .name = name ;
63+ }
64+
65+ public Builder storageClass (StorageClass storageClass ) {
66+ this .storageClass = storageClass ;
67+ return this ;
68+ }
69+
70+ public Builder location (Location location ) {
71+ this .location = location ;
72+ return this ;
73+ }
74+
75+ Builder etag (String etag ) {
76+ this .etag = etag ;
77+ return this ;
78+ }
79+
80+ Builder createTime (Long createTime ) {
4781 this .createTime = createTime ;
82+ return this ;
83+ }
84+
85+ Builder metageneration (Long metageneration ) {
4886 this .metageneration = metageneration ;
87+ return this ;
4988 }
5089
51- public Builder cors (Cors cors ) {
90+ Builder cors (Cors cors ) {
5291 this .cors = cors ;
5392 return this ;
5493 }
5594
56- public Builder acl (Acl acl ) {
57- this .acl = acl ;
95+ public Builder acl (Iterable < Acl > acl ) {
96+ this .acl = ImmutableList . copyOf ( acl ) ;
5897 return this ;
5998 }
6099
61- public Builder defaultAcl (Acl defaultAcl ) {
62- this .defaultAcl = defaultAcl ;
100+ public Builder defaultAcl (Iterable < Acl > acl ) {
101+ this .defaultAcl = ImmutableList . copyOf ( acl ) ;
63102 return this ;
64103 }
65104
@@ -71,11 +110,14 @@ public BucketInfo build() {
71110 private BucketInfo (Builder builder ) {
72111 id = builder .id ;
73112 name = builder .name ;
74- createTime = builder .createTime ;
75- metageneration = builder .metageneration ;
113+ etag = builder .etag ;
114+ createTime = MoreObjects .firstNonNull (builder .createTime , 0L );
115+ metageneration = MoreObjects .firstNonNull (builder .metageneration , 0L );
116+ location = builder .location ;
117+ storageClass = builder .storageClass ;
76118 cors = builder .cors ;
77- acl = builder .acl ;
78- defaultAcl = builder .defaultAcl ;
119+ acl = ImmutableList . copyOf ( builder .acl ) ;
120+ defaultAcl = ImmutableList . copyOf ( builder .defaultAcl ) ;
79121 }
80122
81123 public String id () {
@@ -90,19 +132,31 @@ public Cors cors() {
90132 return cors ;
91133 }
92134
93- public Acl acl () {
135+ public List < Acl > acl () {
94136 return acl ;
95137 }
96138
97- public Acl defaultObjectAcl () {
139+ public List < Acl > defaultObjectAcl () {
98140 return defaultAcl ;
99141 }
100142
101143 public Builder toBuilder () {
102- return builder (id , name , createTime , metageneration ).cors (cors ).acl (acl ).defaultAcl (defaultAcl );
144+ return new Builder (id , name )
145+ .createTime (createTime )
146+ .etag (etag )
147+ .metageneration (metageneration )
148+ .cors (cors )
149+ .acl (acl )
150+ .defaultAcl (defaultAcl )
151+ .location (location )
152+ .storageClass (storageClass );
153+ }
154+
155+ void fromPb (Bucket bucket ) {
156+
103157 }
104158
105- public static Builder builder ( String id , String name , long createTime , long metageneration ) {
106- return new Builder ( id , name , createTime , metageneration );
159+ Bucket toPb ( ) {
160+ return n
107161 }
108162}
0 commit comments