1616
1717package com .google .gcloud .storage ;
1818
19+ import static com .google .common .base .MoreObjects .firstNonNull ;
1920import static com .google .common .base .Preconditions .checkNotNull ;
2021
22+ import com .google .api .client .util .Data ;
2123import com .google .api .client .util .DateTime ;
2224import com .google .api .services .storage .model .ObjectAccessControl ;
2325import com .google .api .services .storage .model .StorageObject ;
@@ -124,22 +126,22 @@ public Builder name(String name) {
124126 }
125127
126128 public Builder contentType (String contentType ) {
127- this .contentType = contentType ;
129+ this .contentType = firstNonNull ( contentType , Data .< String > nullOf ( String . class )) ;
128130 return this ;
129131 }
130132
131133 public Builder contentDisposition (String contentDisposition ) {
132- this .contentDisposition = contentDisposition ;
134+ this .contentDisposition = firstNonNull ( contentDisposition , Data .< String > nullOf ( String . class )) ;
133135 return this ;
134136 }
135137
136138 public Builder contentLanguage (String contentLanguage ) {
137- this .contentLanguage = contentLanguage ;
139+ this .contentLanguage = firstNonNull ( contentLanguage , Data .< String > nullOf ( String . class )) ;
138140 return this ;
139141 }
140142
141143 public Builder contentEncoding (String contentEncoding ) {
142- this .contentEncoding = contentEncoding ;
144+ this .contentEncoding = firstNonNull ( contentEncoding , Data .< String > nullOf ( String . class )) ;
143145 return this ;
144146 }
145147
@@ -149,7 +151,7 @@ Builder componentCount(Integer componentCount) {
149151 }
150152
151153 public Builder cacheControl (String cacheControl ) {
152- this .cacheControl = cacheControl ;
154+ this .cacheControl = firstNonNull ( cacheControl , Data .< String > nullOf ( String . class )) ;
153155 return this ;
154156 }
155157
@@ -179,12 +181,12 @@ Builder selfLink(String selfLink) {
179181 }
180182
181183 public Builder md5 (String md5 ) {
182- this .md5 = md5 ;
184+ this .md5 = firstNonNull ( md5 , Data .< String > nullOf ( String . class )) ;
183185 return this ;
184186 }
185187
186188 public Builder crc32c (String crc32c ) {
187- this .crc32c = crc32c ;
189+ this .crc32c = firstNonNull ( crc32c , Data .< String > nullOf ( String . class )) ;
188190 return this ;
189191 }
190192
@@ -263,7 +265,7 @@ public String name() {
263265 }
264266
265267 public String cacheControl () {
266- return cacheControl ;
268+ return Data . isNull ( cacheControl ) ? null : cacheControl ;
267269 }
268270
269271 public List <Acl > acl () {
@@ -279,19 +281,19 @@ public Long size() {
279281 }
280282
281283 public String contentType () {
282- return contentType ;
284+ return Data . isNull ( contentType ) ? null : contentType ;
283285 }
284286
285287 public String contentEncoding () {
286- return contentEncoding ;
288+ return Data . isNull ( contentEncoding ) ? null : contentEncoding ;
287289 }
288290
289291 public String contentDisposition () {
290- return contentDisposition ;
292+ return Data . isNull ( contentDisposition ) ? null : contentDisposition ;
291293 }
292294
293295 public String contentLanguage () {
294- return contentEncoding ;
296+ return Data . isNull ( contentLanguage ) ? null : contentLanguage ;
295297 }
296298
297299 public Integer componentCount () {
@@ -307,11 +309,11 @@ public String selfLink() {
307309 }
308310
309311 public String md5 () {
310- return md5 ;
312+ return Data . isNull ( md5 ) ? null : md5 ;
311313 }
312314
313315 public String crc32c () {
314- return crc32c ;
316+ return Data . isNull ( crc32c ) ? null : crc32c ;
315317 }
316318
317319 public String mediaLink () {
@@ -367,11 +369,11 @@ public Builder toBuilder() {
367369 @ Override
368370 public String toString () {
369371 return MoreObjects .toStringHelper (this )
370- .add ("bucket" , bucket )
371- .add ("name" , name )
372- .add ("size" , size )
373- .add ("content-type" , contentType )
374- .add ("metadata" , metadata )
372+ .add ("bucket" , bucket () )
373+ .add ("name" , name () )
374+ .add ("size" , size () )
375+ .add ("content-type" , contentType () )
376+ .add ("metadata" , metadata () )
375377 .toString ();
376378 }
377379
@@ -397,7 +399,7 @@ public boolean equals(Object obj) {
397399 if (!(obj instanceof Blob )) {
398400 return false ;
399401 }
400- return Objects .equals (toPb (), ((Blob )obj ).toPb ());
402+ return Objects .equals (toPb (), ((Blob ) obj ).toPb ());
401403 }
402404
403405 StorageObject toPb () {
0 commit comments