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 — Spanner - Improve methods from some of the builder patterns for generic usages · Issue #1805 · googleapis/google-cloud-java

Spanner - Improve methods from some of the builder patterns for generic usages #1805

New issue
Copy link
New issue
Copy link
Closed
Closed
Spanner - Improve methods from some of the builder patterns for generic usages#1805
Copy link
Assignees
vkedia
Labels
api: spannerIssues related to the Spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
Milestone
Spanner GA

Description

@emmanuelbernard
emmanuelbernard
opened on Mar 23, 2017
Issue body actions

When writing things like object mappers, the builder pattern tends to get in the way unless it has some generic input methods. Here is for example the Mutation usage I had to do

        Mutation.WriteBuilder writeBuilder = Mutation.newInsertOrUpdateBuilder( key.getTable() );
		tuplePointer.getTuple().getOperations().forEach( op -> {
			switch ( op.getType() ) {
				case PUT:
					ValueBinder<Mutation.WriteBuilder> set = writeBuilder.set( op.getColumn() );
					Object object = op.getValue();
					//TODO should we convert to Google Spanner native types here or before?
					// e.g. they have their own Date and Timestamp
					if ( object instanceof Timestamp ) {
						set.to( (Timestamp) object );
					}
					else if ( object instanceof Date ) {
						set.to( (Date) object );
					}
					else if ( object instanceof String ) {
						set.to( (String) object );
					}
					else if ( object instanceof Long ) {
						set.to( (Long) object );
					}
					else if ( object instanceof Boolean ) {
						set.to( (Boolean) object );
					}
					else if ( object instanceof Double ) {
						set.to( (Double) object );
					}
					break;
				case PUT_NULL:
				case REMOVE:
					// TODO add metadata related to the type of the column we nullify
					writeBuilder.set( op.getColumn() ).to( (String) null);
                                        break;
			}

		} );
		databaseClient.write( Arrays.asList( writeBuilder.build() ) );

One improvement could be to offer a generic to(Object) method that does the instanceof check for me.

Another possible improvement (that would not help for my case) is to offer

// ideally if types is optional that's even better
setAll(String[] columnNames, Object[] columnValues, Class[] types);

Activity

  1. garrettjonesgoogle
    added
    api: spannerIssues related to the Spanner API.
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Mar 23, 2017
  2. saturnism commented on Apr 8, 2017

    @saturnism
    saturnism
    on Apr 8, 2017
    More actions

    /cc @vkedia

  3. vkedia commented on Apr 20, 2017

    @vkedia
    vkedia
    on Apr 20, 2017
    More actions

    @emmanuelbernard @saturnism I think this is a reasonable request. We can add a .to(Object) to the ValueBinder class. One hitch here is how to make this method work for arrays since instanceof will not tell us the type of the iterable.

  4. emmanuelbernard commented on May 3, 2017

    @emmanuelbernard
    emmanuelbernard
    on May 3, 2017
    Author
    More actions

    @vkedia right. In that case, you could make a pair of explicitly named methods like toObject(Object) toIterable(Iterable value, Class<?> type).

  5. shinfan
    modified the milestone: Spanner GA on May 8, 2017
  6. garrettjonesgoogle
    added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on May 30, 2017
  7. garrettjonesgoogle
    assigned
    vkedia
    on Aug 11, 2017
  8. yihanzhen commented on Jan 11, 2018

    @yihanzhen
    yihanzhen
    on Jan 11, 2018
    Contributor
    More actions

    The feature request is added to the backlog. The issue will be closed but is linked in the backlog and can continue to be used for comment and discussion.

  9. yihanzhen
    closed this as completedon Jan 11, 2018
  10. meltsufin
    added a commit that references this issue on Dec 22, 2025

    chore(main): release 3.22.4-SNAPSHOT (#1805)

    644ebd7
  11. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore: Update generation configuration at Thu Mar 27 02:26:48 UTC 2025 (

    8ceb62b
  12. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore(main): release 3.22.4-SNAPSHOT (googleapis#1805)

    3648f4b
  13. lqiu96
    added a commit that references this issue on Mar 20, 2026

    chore: Update generation configuration at Thu Mar 27 02:26:48 UTC 2025 (

    5c0b330
  14. suztomo
    added a commit that references this issue on Mar 23, 2026

    chore(main): release 2.24.1-SNAPSHOT (googleapis#1805)

    fd56dad
  15. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    chore: Set blunderbuss config to auto-assign issues and PRs (#1805)

    2e756d6

    chore: Set blunderbuss config to auto-assign issues and PRs (#1805)

    f74a943
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @vkedia
    vkedia

Labels

api: spannerIssues related to the Spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    • Spanner GA

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.