GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Convert all BigQuery deserialized enum types to StringEnumValue by tcoffee-google · Pull Request #2128 · googleapis/google-cloud-java

Conversation

@tcoffee-google

@tcoffee-google tcoffee-google commented Jun 8, 2017

Copy link
Copy Markdown
Contributor

Introduces generalization of pattern for Storage/Datastore/Logging to simulate enum types with
single data members. This appears to cover all cases in remaining Cloud APIs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tcoffee-google
Convert all BigQuery deserialized enum types to StringEnumValue
7aeab93
Introduces generalization of pattern for Storage/Datastore/Logging to simulate enum types with
single data members. This appears to cover all cases in remaining Cloud APIs.
@tcoffee-google
tcoffee-google requested a review from garrettjonesgoogle June 8, 2017 17:53
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 8, 2017
@tcoffee-google

tcoffee-google commented Jun 8, 2017

Copy link
Copy Markdown
Contributor Author

Posting BigQuery for design review before converting remaining APIs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Jun 8, 2017

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 7aeab93 on tcoffee-google:string_enum_bigquery into ** on GoogleCloudPlatform:master**.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

garrettjonesgoogle
garrettjonesgoogle reviewed Jun 9, 2017
View reviewed changes
Comment thread google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/LegacySQLTypeName.java Outdated
private StandardSQLTypeName equivalent;

LegacySQLTypeName(StandardSQLTypeName equivalent) {
LegacySQLTypeName setStandardType(StandardSQLTypeName equivalent) {

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@garrettjonesgoogle
garrettjonesgoogle requested a review from shinfan June 9, 2017 01:25
@tcoffee-google
Make field setter private
389bbdd
@tcoffee-google

tcoffee-google commented Jun 9, 2017

Copy link
Copy Markdown
Contributor Author

@garrettjonesgoogle would you agree with the codacy-bot recommendation here? If so, I can retroactively change the previously published StringEnumValue subclasses as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Jun 9, 2017

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 389bbdd on tcoffee-google:string_enum_bigquery into ** on GoogleCloudPlatform:master**.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shinfan

shinfan commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

It would be nice to fix the codacy-bot suggestions... Those posts make the page very long and hard to scroll...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@garrettjonesgoogle

garrettjonesgoogle commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

@tcoffee-google sure, let's take care of the codacy recommendations.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tcoffee-google
Move fields to top
6c716d5
@tcoffee-google

tcoffee-google commented Jun 9, 2017

Copy link
Copy Markdown
Contributor Author

Fixed for BigQuery --- I'll change this others once this one is approved.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@garrettjonesgoogle

garrettjonesgoogle commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tcoffee-google
Move fields to top
f45aebd
@tcoffee-google

tcoffee-google commented Jun 9, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

For reference in case of future maintenance, the enums to be converted were found from instances of the (Emacs-style) regexp

\( *\)\(\w+ \)*fromPb(.*) {
\(\1  .*
\)*?\1  .*?valueOf.*
\(\1  .*
\)*?\1}

and conversions were done by fixed-point application of the following regexp replacements (the first two are sufficient for cases without subfields):

  1. convert enum to class
\( *\)\(\(\w+ \)*\)?enum \(\w+\) {
\(\(\(\1  .*\)?
\)*\)\1}

=>

\1\2static final class \4 extends StringEnumValue {
\1  private static final long serialVersionUID = \,(random)L;

\1  private static final ApiFunction<String, \4> CONSTRUCTOR =
\1      new ApiFunction<String, \4>() {
\1        @Override
\1        public \4 apply(String constant) {
\1          return new \4(constant);
\1        }
\1      };

\1  private static final StringEnumType<\4> type = new StringEnumType(
\1      \4.class,
\1      CONSTRUCTOR);

\5
\1  private \4(String constant) {
\1    super(constant);
\1  }

\1  /**
\1   * Get the \4 for the given String constant, and throw an exception if the constant is
\1   * not recognized.
\1   */
\1  \2static \4 valueOfStrict(String constant) {
\1    return type.valueOfStrict(constant);
\1  }

\1  /**
\1   * Get the \4 for the given String constant, and allow unrecognized values.
\1   */
\1  \2static \4 valueOf(String constant) {
\1    return type.valueOf(constant);
\1  }

\1  /**
\1   * Return the known values for \4.
\1   */
\1  \2static \4[] values() {
\1    return type.values();
\1  }
\1}

(removing the initial "static" for top-level enums)

  1. convert values to fields
\( *\)\(\(\w+ \)*\)class \(\w+\)\( extends StringEnumValue {
\(\(\1  .*\)?
\)*?\)\1  \([A-Z0-9_]+\)\(?:[,;]?\)\(
\(\(\1  .*\)?
\)*\1}\)

=>

\1\2class \4\5\1  \2\4 \8 = type.createAndRegister("\8");\9
  1. convert subfielded values to fields
\( *\)\(\(?:\w+ \)*\)class \(\w+\)\( extends StringEnumValue {
\(?:\(?:\1  .*\)?
\)*?\)\1  \([A-Z0-9_]+\)(\(.+\))\(?:[,;]?\)\(
\(?:\(?:\1  .*\)?
\)*\)\1  \3\((\(\w+\) \w+) {
\(?:\(?:\1  .*\)?
\)*\1  .+ \9 get\(\w+\)() {
\(?:\(?:\1  .*\)?
\)*\1}\)

=>

\1\2class \3\4\1  \2\3 \5 = type.createAndRegister("\5").set\,(match-string 10)(\6);\7\1  \3\8
  1. convert subfield constructor to setter
\( *\)\(\(?:\w+ \)*\)class \(\w+\)\( extends StringEnumValue {
\(?:\(?:\1  .*\)?
\)*?\)\1  \3\((\(\w+\) \w+) {
\(?:\(?:\1  .*\)?
\)*?\)\(\1  }
\(?:\(?:\1  .*\)?
\)*\1  .+ \6 get\(\w+\)() {
\(?:\(?:\1  .*\)?
\)*\1}\)

=>

\1\2class \3\4\1  private \3 set\8\5\1    return this;
\7
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Jun 9, 2017

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling f45aebd on tcoffee-google:string_enum_bigquery into ** on GoogleCloudPlatform:master**.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Jun 9, 2017

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling f45aebd on tcoffee-google:string_enum_bigquery into ** on GoogleCloudPlatform:master**.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tcoffee-google
tcoffee-google merged commit ae640b7 into googleapis:master Jun 9, 2017
@tcoffee-google
tcoffee-google deleted the string_enum_bigquery branch June 9, 2017 22:12
@tcoffee-google

tcoffee-google commented Jun 9, 2017

Copy link
Copy Markdown
Contributor Author

Addresses #1944.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jun 10, 2017
Convert all DNS deserialized enum types to StringEnumValue #2137
Merged
Convert all Compute deserialized enum types to StringEnumValue #2136
Merged
Convert all Resource Manager deserialized enum types to StringEnumValue #2138
Merged
chingor13 pushed a commit that referenced this pull request Feb 20, 2026
@renovate-bot
deps: update dependency com.google.cloud:google-cloud-bigquery to v2.…
62afd46
…26.1 (#2128)
chingor13 pushed a commit that referenced this pull request Feb 20, 2026
@release-please
chore(main): release 2.37.2 (#2127)
13ac7bb
🤖 I have created a release *beep* *boop*
---


## [2.37.2](https://togithub.com/googleapis/java-bigquerystorage/compare/v2.37.1...v2.37.2) (2023-05-30)


### Bug Fixes

* Pass the parameter value of enableConnectionPool instead of true always ([#2096](https://togithub.com/googleapis/java-bigquerystorage/issues/2096)) ([253678d](https://togithub.com/googleapis/java-bigquerystorage/commit/253678df630c717fbcf7018b3245aa56b5f22660))


### Dependencies

* Update dependency com.google.cloud:google-cloud-bigquery to v2.26.0 ([#2114](https://togithub.com/googleapis/java-bigquerystorage/issues/2114)) ([8b44534](https://togithub.com/googleapis/java-bigquerystorage/commit/8b4453476b17dcbb10faaa52c6a2b06506d89d62))
* Update dependency com.google.cloud:google-cloud-bigquery to v2.26.1 ([#2128](https://togithub.com/googleapis/java-bigquerystorage/issues/2128)) ([62afd46](https://togithub.com/googleapis/java-bigquerystorage/commit/62afd46bb4cad09886c49bac88a2052c8754f8fe))
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.10.1 ([#2121](https://togithub.com/googleapis/java-bigquerystorage/issues/2121)) ([3fabc5d](https://togithub.com/googleapis/java-bigquerystorage/commit/3fabc5d467becd3d9b816f9545e8a1e6dd09f682))
* Update dependency com.google.http-client:google-http-client to v1.43.2 ([#2109](https://togithub.com/googleapis/java-bigquerystorage/issues/2109)) ([0d57daf](https://togithub.com/googleapis/java-bigquerystorage/commit/0d57daff0d113089ba1957753febeed92024e4c2))
* Update dependency com.google.truth:truth to v1.1.4 ([#2126](https://togithub.com/googleapis/java-bigquerystorage/issues/2126)) ([a0be7ad](https://togithub.com/googleapis/java-bigquerystorage/commit/a0be7ad59b1604972b190befe2e4befd2e2c6431))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 23, 2026
@olavloite
test: check for credentials for traces (googleapis#2128)
1b64951
Add an explicit check to the test whether there are credentials available.
meltsufin pushed a commit that referenced this pull request Apr 29, 2026
@zhumin8
chore: setup 1.129.x lts branch (#2128)
dfe7739
meltsufin pushed a commit that referenced this pull request May 1, 2026
@zhumin8
chore: setup 1.129.x lts branch (#2128)
e139db3
meltsufin pushed a commit that referenced this pull request May 2, 2026
@renovate-bot
deps: update dependency com.diffplug.spotless:spotless-maven-plugin t…
2d06fb6
…o v2.44.5 (#2128)
benjaminp pushed a commit to benjaminp/google-cloud-java that referenced this pull request Jul 13, 2026
@release-please
chore(main): release 2.34.1-SNAPSHOT (googleapis#2128)
c774514
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@shinfan shinfan Awaiting requested review from shinfan
1 more reviewer
@garrettjonesgoogle garrettjonesgoogle garrettjonesgoogle left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@tcoffee-google @coveralls @shinfan @garrettjonesgoogle @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.