Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Result / Record construction API #4507

Closed
lukaseder opened this issue Sep 1, 2015 · 1 comment
Closed

Improve Result / Record construction API #4507

lukaseder opened this issue Sep 1, 2015 · 1 comment

Comments

@lukaseder
Copy link
Member

Currently, when constructing Result types (e.g. for the mock API), something like the following logic has to be used:

Field<Integer> key = DSL.field("key", Integer.class); 
Field<String> value = DSL.field("value", String.class);

Result<Record2<Integer, String>> result = create.newResult(key, value); 
result.add(create.newRecord(key, value)); 
result.get(0).setValue(key, 1); 
result.get(0).setValue(value, "1"); 
result.add(create.newRecord(key, value)); 
result.get(1).setValue(key, 2); 
result.get(1).setValue(value, "2"); 
mock[0] = new MockResult(2, result);

This is rather cumbersome and repetitive:

  • The columns have to be specified many times
  • All setters return void and cannot be chained

Something like this would be much better, conceptually:

mock[0] = new MockResult(2,
    create.newResult(key, value)
          .withRecord(1, "1")
          .withRecord(2, "2")
);

The above example is not possible from a generic type safety perspective - but another solution may be.

@lukaseder
Copy link
Member Author

I didn't find a better solution for this API in all these years. Closing as won't fix

3.18 Other improvements automation moved this from To do to Done Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

1 participant