@@ -96,6 +96,7 @@ public StorageObject apply(BlobInfo blobInfo) {
9696 private final String contentDisposition ;
9797 private final String contentLanguage ;
9898 private final StorageClass storageClass ;
99+ private final Long timeStorageClassUpdated ;
99100 private final Integer componentCount ;
100101 private final boolean isDirectory ;
101102 private final CustomerEncryption customerEncryption ;
@@ -297,6 +298,16 @@ public Builder setCustomTime(Long customTime) {
297298 /** Sets the blob's storage class. */
298299 public abstract Builder setStorageClass (StorageClass storageClass );
299300
301+ /**
302+ * Sets the modification time of an object's storage class. Once set it can't be unset directly,
303+ * the only way is to rewrite the object with the desired storage class.
304+ */
305+ public Builder setTimeStorageClassUpdated (Long timeStorageClassUpdated ) {
306+ throw new UnsupportedOperationException (
307+ "Override setTimeStorageClassUpdated with your own implementation,"
308+ + " or use com.google.cloud.storage.Blob." );
309+ }
310+
300311 /** Sets the blob's user provided metadata. */
301312 public abstract Builder setMetadata (Map <String , String > metadata );
302313
@@ -356,6 +367,7 @@ static final class BuilderImpl extends Builder {
356367 private Boolean isDirectory ;
357368 private CustomerEncryption customerEncryption ;
358369 private StorageClass storageClass ;
370+ private Long timeStorageClassUpdated ;
359371 private String kmsKeyName ;
360372 private Boolean eventBasedHold ;
361373 private Boolean temporaryHold ;
@@ -391,6 +403,7 @@ static final class BuilderImpl extends Builder {
391403 createTime = blobInfo .createTime ;
392404 isDirectory = blobInfo .isDirectory ;
393405 storageClass = blobInfo .storageClass ;
406+ timeStorageClassUpdated = blobInfo .timeStorageClassUpdated ;
394407 kmsKeyName = blobInfo .kmsKeyName ;
395408 eventBasedHold = blobInfo .eventBasedHold ;
396409 temporaryHold = blobInfo .temporaryHold ;
@@ -564,6 +577,12 @@ public Builder setStorageClass(StorageClass storageClass) {
564577 return this ;
565578 }
566579
580+ @ Override
581+ public Builder setTimeStorageClassUpdated (Long timeStorageClassUpdated ) {
582+ this .timeStorageClassUpdated = timeStorageClassUpdated ;
583+ return this ;
584+ }
585+
567586 @ Override
568587 Builder setMetageneration (Long metageneration ) {
569588 this .metageneration = metageneration ;
@@ -657,6 +676,7 @@ public BlobInfo build() {
657676 createTime = builder .createTime ;
658677 isDirectory = firstNonNull (builder .isDirectory , Boolean .FALSE );
659678 storageClass = builder .storageClass ;
679+ timeStorageClassUpdated = builder .timeStorageClassUpdated ;
660680 kmsKeyName = builder .kmsKeyName ;
661681 eventBasedHold = builder .eventBasedHold ;
662682 temporaryHold = builder .temporaryHold ;
@@ -917,6 +937,14 @@ public StorageClass getStorageClass() {
917937 return storageClass ;
918938 }
919939
940+ /**
941+ * Returns the time that the object's storage class was last changed or the time of the object
942+ * creation.
943+ */
944+ public Long getTimeStorageClassUpdated () {
945+ return timeStorageClassUpdated ;
946+ }
947+
920948 /** Returns the Cloud KMS key used to encrypt the blob, if any. */
921949 public String getKmsKeyName () {
922950 return kmsKeyName ;
@@ -1049,6 +1077,9 @@ public ObjectAccessControl apply(Acl acl) {
10491077 if (storageClass != null ) {
10501078 storageObject .setStorageClass (storageClass .toString ());
10511079 }
1080+ if (timeStorageClassUpdated != null ) {
1081+ storageObject .setTimeStorageClassUpdated (new DateTime (timeStorageClassUpdated ));
1082+ }
10521083
10531084 Map <String , String > pbMetadata = metadata ;
10541085 if (metadata != null && !Data .isNull (metadata )) {
@@ -1193,6 +1224,9 @@ public Acl apply(ObjectAccessControl objectAccessControl) {
11931224 if (storageObject .getStorageClass () != null ) {
11941225 builder .setStorageClass (StorageClass .valueOf (storageObject .getStorageClass ()));
11951226 }
1227+ if (storageObject .getTimeStorageClassUpdated () != null ) {
1228+ builder .setTimeStorageClassUpdated (storageObject .getTimeStorageClassUpdated ().getValue ());
1229+ }
11961230 if (storageObject .getKmsKeyName () != null ) {
11971231 builder .setKmsKeyName (storageObject .getKmsKeyName ());
11981232 }
0 commit comments