-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat/chainable translators #542
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I trust you on the Maven config bits here, because I am not this familiar with this (foremost japicmp
).
Some remarks in the comments.
|
||
@Override | ||
public String apply(String sql) { | ||
if (this.translators.size() == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding readability / maintenance:
Is this special handling for size == 1 really needed?
Yes, the iterator is not invoked here and it might have performance benefits but shouldn't take the JVM care of optimising this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Burned by this too many times wrt streams.
} | ||
|
||
private int getOrder(SqlTranslator sqlTranslator) { | ||
if (sqlTranslator != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point the SqlTranslator
should never be null
.
Maybe a check in the public compare
method for this with potential exception throwing. I mean even Java built-in types have no nice mitigation for null
values on compare.
What might be checked for null
is the value of SqlTranslator#getOrder
because it can be overwritten to return null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't return null
, only 0
, it's an int
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 myself..nothing to see here 😄
The former is provided for two reasons: It allows us to distribute the driver with and without the bundled, default translator and can be an option for you to run your custom translator. | ||
|
||
Translators can be chained, and you can have as many translators on the class-path as you want. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translators can be chained, and you can have as many translators on the class-path as you want. | |
Translators can be chained, and you can have as many translators on the class path as you want. |
Also note that there is as well classpath in the current documentation. This should get unified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most official docs use classpath
(Edit: Geez autocorrect)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then my suggestion is of course
Translators can be chained, and you can have as many translators on the class-path as you want. | |
Translators can be chained, and you can have as many translators on the classpath as you want. |
😺
1877401
to
445797e
Compare
SQL translators now can be ordered and you can have as many SQL translator factories as you want on the class- or module-path. The will be called in order of highest precedence, and individual translators but the last are free to fail or to modify the intermediate statement. No additional translators are provided in this commit. Co-authored-by: Gerrit Meier <[email protected]>
d289010
to
641daa4
Compare
@since
tags.