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

datatable/java: Support for Optional<T> #1182

Merged
merged 19 commits into from
Sep 26, 2020

Conversation

rasklaad
Copy link

@rasklaad rasklaad commented Sep 13, 2020

Summary

Ability to use a tables with Optional types.

Details

I've added a new TableCellTransformers.

Motivation and Context

#1091

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • The change has been ported to Java.
  • The change has been ported to Ruby.
  • The change has been ported to JavaScript.
  • The change has been ported to Go.
  • The change has been ported to .NET.
  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have updated the CHANGELOG accordingly.

Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

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

Looking good! Though the code is a bit repetitive. You can probably use lambda functions or method references to extract out the common parts.

aslakhellesoy and others added 5 commits September 13, 2020 20:45
@mpkorstanje
Copy link
Contributor

@rasklaad I've been playing around a bit with automatically registering the optional variant of every table cell transformer that is registered. The problem is a bit more complicated because I'm also adding a new OptionalType which means that DataTableTypeRegistryTableConverter is missing a few cases that would previously be covered by OtherType. However I do think it will be a better solution.

https://github.com/cucumber/cucumber/tree/datatable-java-optional-type-replacement

@mpkorstanje
Copy link
Contributor

@rasklaad I've pushed some changes.

Instead of registering transformers for all optionals, we'll look at the type we are trying to convert too. If the type we are trying to convert too is an optional and has an a regular transformer then we'll wrap the regular transformer in an optional transformer and return that.

Now I had to throw a whole bunch of tests away. They weren't interesting. They all covered the same thing. When a cell transformer is registered for a type it also works for the optional variant of that type. So we don't need to check all types.

What do you think?

@mpkorstanje mpkorstanje changed the title Datatable: Support for Optional datatable/java: Support for Optional Sep 26, 2020
@mpkorstanje mpkorstanje changed the title datatable/java: Support for Optional datatable/java: Support for Optional<T> Sep 26, 2020
@mpkorstanje mpkorstanje merged commit d0f6307 into master Sep 26, 2020
@mpkorstanje mpkorstanje deleted the datatable-java-optional-type branch September 26, 2020 19:48
@mpkorstanje
Copy link
Contributor

I think this will do. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants