Skip to content

Conversation

@BenWhitehead
Copy link
Collaborator

@BenWhitehead BenWhitehead commented May 16, 2022

What's been added

Fields which map to apiary DateTime RFC 3339 fields will now also have
a preferred java.time.OffsetDateTime getter & setter.

Fields which map to apiary long to represent a duration in epoch millis
will no also have a preferred java.time.Duration getter & setter.

All new methods currently have the name of the corresponding java.time
type appended to the property name.

Refactor Long -> java.time.OffsetDateTime

  • BlobInfo#createTime
  • BlobInfo#customTime
  • BlobInfo#deleteTime
  • BlobInfo#retentionExpirationTime
  • BlobInfo#timeStorageClassUpdated
  • BlobInfo#updateTime
  • Blob#createTime
  • Blob#customTime
  • Blob#deleteTime
  • Blob#retentionExpirationTime
  • Blob#timeStorageClassUpdated
  • Blob#updateTime
  • BucketInfo.CreatedBeforeDeleteRule
  • BucketInfo.DeleteRule
  • BucketInfo.IsLiveDeleteRule
  • BucketInfo.NumNewerVersionsDeleteRule
  • BucketInfo.RawDeleteRule
  • BucketInfo#createTime
  • BucketInfo#updateTime
  • Bucket#createTime
  • Bucket#updateTime
  • Bucket#retentionEffectiveTime
  • HmacKey.HmacKeyMetadata#createTime
  • HmacKey.HmacKeyMetadata#updateTime

Refactor Long -> java.time.Duration

  • BucketInfo#retentionPeriod
  • Bucket#retentionPeriod

Deprecation of existing methods

All existing "Long" based methods have been marked as @Deprecated
and had their javadocs updated to point to the new preferred
corresponding java.time method.

When the existing "Long" based methods are removed, the corresponding
java.time method will replace it at which point the java.time suffix
methods will be deprecated for later cleanup.

All existing "Long" based methods take care of performing the necessary
conversion to the respective java.time type and will continue to work
until their removal.

Why append the java.time type as a suffix?
  1. Getters can't be overloaded, so we already need something to disambiguate
    which type should be returned.
  2. For setters: we theoretically could overload since we have different
    method arguments, however, if a customer is already passing null as the
    method argument we've now created an ambiguity as to which method to
    invoke. By suffixing the setters as well, we avoid creating this possible
    ambiguity.

Part 2 of #1388

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/java-storage API. labels May 16, 2022
@BenWhitehead BenWhitehead marked this pull request as ready for review May 16, 2022 17:49
@BenWhitehead BenWhitehead requested a review from a team as a code owner May 16, 2022 17:49
@BenWhitehead BenWhitehead force-pushed the time-pt2 branch 3 times, most recently from 77ce6cb to 39de58d Compare May 16, 2022 18:31
@BenWhitehead BenWhitehead changed the title feat: refactor Model classes to prefer to java.time types feat: refactor model classes to prefer to java.time types May 16, 2022
@BenWhitehead BenWhitehead force-pushed the time-pt2 branch 2 times, most recently from b09c998 to a3e8e78 Compare May 24, 2022 17:42
### What's been added

Fields which map to apiary DateTime RFC 3339 fields will now also have
a preferred java.time.OffsetDateTime getter & setter.

Fields which map to apiary long to represent a duration in epoch millis
will no also have a preferred java.time.Duration getter & setter.

All new methods currently have the name of the corresponding java.time
type appended to the property name.

#### Refactor Long -> java.time.OffsetDateTime
* BlobInfo#createTime
* BlobInfo#customTime
* BlobInfo#deleteTime
* BlobInfo#retentionExpirationTime
* BlobInfo#timeStorageClassUpdated
* BlobInfo#updateTime
* Blob#createTime
* Blob#customTime
* Blob#deleteTime
* Blob#retentionExpirationTime
* Blob#timeStorageClassUpdated
* Blob#updateTime
* BucketInfo.CreatedBeforeDeleteRule
* BucketInfo.DeleteRule
* BucketInfo.IsLiveDeleteRule
* BucketInfo.NumNewerVersionsDeleteRule
* BucketInfo.RawDeleteRule
* BucketInfo#createTime
* BucketInfo#updateTime
* Bucket#createTime
* Bucket#updateTime
* Bucket#retentionEffectiveTime
* HmacKey.HmacKeyMetadata#createTime
* HmacKey.HmacKeyMetadata#updateTime

#### Refactor Long -> java.time.Duration
* BucketInfo#retentionPeriod
* Bucket#retentionPeriod

### Deprecation of existing methods
All existing "Long" based methods have been marked as `@Deprecated`
and had their javadocs updated to point to the new preferred
corresponding java.time method.

When the existing "Long" based methods are removed, the corresponding
java.time method will replace it at which point the java.time suffix
methods will be deprecated for later cleanup.

All existing "Long" based methods take care of performing the necessary
conversion to the respective java.time type and will continue to work
until their removal.

##### Why append the java.time type as a suffix?
1. Getters can't be overloaded, so we already need something to disambiguate
   which type should be returned.
2. For setters: we theoretically could overload since we have different
   method arguments, however, if a customer is already passing `null` as the
   method argument we've now created an ambiguity as to which method to
   invoke. By suffixing the setters as well, we avoid creating this possible
   ambiguity.
Copy link
Contributor

@sydney-munro sydney-munro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a small nit.

@Deprecated
Builder setRetentionEffectiveTime(Long retentionEffectiveTime) {
return setRetentionEffectiveTime(millisOffsetDateTimeCodec.encode(retentionEffectiveTime));
return setRetentionEffectiveTimeOffsetDateTime(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: inconsistencies between style.
before you do

Builder setUpdateTime(Long updateTime) {
      this.updateTime = millisOffsetDateTimeCodec.encode(updateTime);
      return this;
    }

vs calling the offset method in the deprecated old method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree this feels bad.

The method where the new one, calls the existing deprecated method is there to provide binary compatibility on the base builder. For reasons lost to time, the base builder is all public and someone theoretically could have extended it. In our implementations, I then do the proper order of the deprecated method calling the new method.

@BenWhitehead BenWhitehead merged commit 95e5595 into feat/grpc-storage May 25, 2022
@BenWhitehead BenWhitehead deleted the time-pt2 branch May 25, 2022 16:18
sydney-munro pushed a commit that referenced this pull request Jun 7, 2022
### What's been added

Fields which map to apiary DateTime RFC 3339 fields will now also have
a preferred java.time.OffsetDateTime getter & setter.

Fields which map to apiary long to represent a duration in epoch millis
will no also have a preferred java.time.Duration getter & setter.

All new methods currently have the name of the corresponding java.time
type appended to the property name.

#### Refactor Long -> java.time.OffsetDateTime
* BlobInfo#createTime
* BlobInfo#customTime
* BlobInfo#deleteTime
* BlobInfo#retentionExpirationTime
* BlobInfo#timeStorageClassUpdated
* BlobInfo#updateTime
* Blob#createTime
* Blob#customTime
* Blob#deleteTime
* Blob#retentionExpirationTime
* Blob#timeStorageClassUpdated
* Blob#updateTime
* BucketInfo.CreatedBeforeDeleteRule
* BucketInfo.DeleteRule
* BucketInfo.IsLiveDeleteRule
* BucketInfo.NumNewerVersionsDeleteRule
* BucketInfo.RawDeleteRule
* BucketInfo#createTime
* BucketInfo#updateTime
* Bucket#createTime
* Bucket#updateTime
* Bucket#retentionEffectiveTime
* HmacKey.HmacKeyMetadata#createTime
* HmacKey.HmacKeyMetadata#updateTime

#### Refactor Long -> java.time.Duration
* BucketInfo#retentionPeriod
* Bucket#retentionPeriod

### Deprecation of existing methods
All existing "Long" based methods have been marked as `@Deprecated`
and had their javadocs updated to point to the new preferred
corresponding java.time method.

When the existing "Long" based methods are removed, the corresponding
java.time method will replace it at which point the java.time suffix
methods will be deprecated for later cleanup.

All existing "Long" based methods take care of performing the necessary
conversion to the respective java.time type and will continue to work
until their removal.

##### Why append the java.time type as a suffix?
1. Getters can't be overloaded, so we already need something to disambiguate
   which type should be returned.
2. For setters: we theoretically could overload since we have different
   method arguments, however, if a customer is already passing `null` as the
   method argument we've now created an ambiguity as to which method to
   invoke. By suffixing the setters as well, we avoid creating this possible
   ambiguity.
KengoTODA added a commit to KengoTODA/gradle-gcs-build-cache that referenced this pull request Jan 13, 2023
refs googleapis/java-storage#1394

Signed-off-by: Kengo TODA <skypencil@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the googleapis/java-storage API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants