-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
cucumber-expressions: Prefer Java type hint over parameter type #659
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mpkorstanje
force-pushed
the
prefer-type-hint--over-parameter-type
branch
from
July 19, 2019 14:32
7644833
to
f1add95
Compare
Tip @mpkorstanje - rather than creating a PR prefixed with |
Cool. That's new. Thanks. |
11 tasks
When there is a conflict between the type hint from the regular expression and the method prefer the the parameter type associated with the regular expression. This ensures we will use the internal/user registered parameter transformer rather then the default. Unless the parameter type indicates it is the stronger type hint. Reasoning: 1. Pure cucumber expression users will not notice this in either scenario. 2. Pure regular expression users will benefit because `BuiltInParameterTransformer` can now seamlessly transform any captured values. (For all built in types useRegexpMatchAsStrongTypeHint is explicitly set to false.) 2. Regular expression users that define a default transformer have little need to define parameter types. The default transformer should be sufficiently powerful to meet their needs and will often allow users to add custom creation methods e.g. Jacksons @JsonFactory. 3. Users who mix regular and cucumber expressions may run into conflicts when a registered cucumber expression and unregistered happens to collide. However this was the situation before this flag was added. 4. Regular expression users who define custom parameter types do so with the expectation that the parameter will be matched. Subverting this expectation when the method signature does not match may result in a parameter transformer that is unable to convert to the desired type. Leaving the user puzzled as to why his transform was ignored. Fixes: #658
mpkorstanje
force-pushed
the
prefer-type-hint--over-parameter-type
branch
from
August 2, 2019 21:40
f1add95
to
f90958d
Compare
mpkorstanje
changed the title
WIP: cucumber-expressions: Prefer Java type hint over parameter type
cucumber-expressions: Prefer Java type hint over parameter type
Aug 2, 2019
When there is a conflict between the type hint from the regular expression and the method prefer the the parameter type associated with the regular expression. This ensures we will use the internal/user registered parameter transformer rather then the default. Unless the parameter type indicates it is the stronger type hint. Reasoning: 1. Pure cucumber expression users will not notice this in either scenario. 2. Pure regular expression users will benefit because `BuiltInParameterTransformer` can now seamlessly transform any captured values. (For all built in types `useRegexpMatchAsStrongTypeHint` is explicitly set to false.) 2. Regular expression users that define a default transformer have little need to define parameter types. The default transformer should be sufficiently powerful to meet their needs and will often allow users to add custom creation methods e.g. Jacksons @JsonFactory. 3. Users who mix regular and cucumber expressions may run into conflicts when a registered cucumber expression and unregistered happens to collide. However this was the situation before this flag was added. 4. Regular expression users who define custom parameter types do so with the expectation that the parameter will be matched. Subverting this expectation when the method signature does not match may result in a parameter transformer that is unable to convert to the desired type. Leaving the user puzzled as to why his transform was ignored.
Implemented Go too. |
I'll merge this by the next of next week unless there are any more comments. Then we can bundle it up for the next release of cucumber expressions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When there is a conflict between the type hint from the regular expression
and the method prefer the the parameter type associated with the regular
expression. This ensures we will use the internal/user registered parameter
transformer rather then the default.
Unless the parameter type indicates it is the stronger type hint.
Details
Reasoning:
BuiltInParameterTransformer
can now seamlessly transform any capturedvalues. (For all built in types
useRegexpMatchAsStrongTypeHint
isexplicitly set to false.)
need to define parameter types. The default transformer should be
sufficiently powerful to meet their needs and will often allow users to
add custom creation methods e.g. Jacksons @JsonFactory.
when a registered cucumber expression and unregistered happens to
collide. However this was the situation before this flag was added.
the expectation that the parameter will be matched. Subverting this
expectation when the method signature does not match may result in a
parameter transformer that is unable to convert to the desired type.
Leaving the user puzzled as to why his transform was ignored.
Motivation and Context
Fixes: #658
Types of changes
Checklist: