-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate model classes to use java.time instead of Long (#1388)
* Add Codec<DateTime, OffsetDateTime> for apiary conversion * Add Utils#RFC_3339_DATE_TIME_FORMATTER * Add Utils#millisOffsetDateTimeCodec to provide compatibility with existing Long centric apis * Update BucketInfo and BucketInfo.Builder to prefer java.time types instead of Long * Update ApiaryConversions for BucketInfo to use new java.time types Update the following files to now be OffestDateTime instead of Long * BlobInfo#customTime * BlobInfo#deleteTime * BlobInfo#updateTime * BlobInfo#createTime * BlobInfo#timeStorageClassUpdated * BlobInfo#retentionExpirationTime * BucketInfo#retentionEffectiveTime * IamConfiguration#uniformBucketLevelAccessLockedTime
- Loading branch information
1 parent
1600f5e
commit a2e9b88
Showing
8 changed files
with
503 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
google-cloud-storage/src/main/java/com/google/cloud/storage/BackwardCompatibilityUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.storage; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import com.google.cloud.storage.Conversions.Codec; | ||
import java.time.Instant; | ||
import java.time.OffsetDateTime; | ||
import java.time.ZoneOffset; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
/** | ||
* A collection of utilities that only exist to enable backward compatibility. | ||
* | ||
* <p>In general, the expectation is that any references to this class only come from @Deprecated | ||
* things. | ||
*/ | ||
final class BackwardCompatibilityUtils { | ||
|
||
@SuppressWarnings("RedundantTypeArguments") | ||
// the <Long, OffsetDateTime> doesn't auto carry all the way through like intellij thinks it | ||
// would. | ||
static final Codec<@Nullable Long, @Nullable OffsetDateTime> millisOffsetDateTimeCodec = | ||
Codec.<Long, OffsetDateTime>of( | ||
m -> | ||
Instant.ofEpochMilli(requireNonNull(m, "m must be non null")) | ||
.atOffset(ZoneOffset.systemDefault().getRules().getOffset(Instant.now())), | ||
odt -> requireNonNull(odt, "odt must be non null").toInstant().toEpochMilli()) | ||
.nullable(); | ||
|
||
private BackwardCompatibilityUtils() {} | ||
} |
Oops, something went wrong.