-
Notifications
You must be signed in to change notification settings - Fork 0
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
Visitor for UpdateClause class hierarchy #21
base: main
Are you sure you want to change the base?
Conversation
* @return the possibly transformed value resulting from the visitation. | ||
*/ | ||
default <T> T accept(UpdateClauseVisitor<T> visitor) { | ||
throw new IllegalArgumentException(); |
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.
We had gotten advice that we shouldn't use defaults, simply leave as abstract.
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.
Done
|
||
ExpressionPath getPath(); | ||
|
||
class SetCommand implements UpdateCommand { |
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.
Can you use Immutables for these two?
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.
Done, but needed to move class higher so it would generate Immutable class.
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.
This seems incorrect: immutables/immutables#23 ?
Or is it the case that an immutable can only work if it's nested in a parent immutable?
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 have corrected this. I moved the interface UpdateCommand
into the TestUpdateClauseVisitor
class and nested the RemoveCommand
and SetCommand
classes under that. It all looks much better now. I think IntelliJ was not refreshed before I checked for the generated test classes in generated-test-sources.
} | ||
|
||
void testSetClause(UpdateClause clause, ExpressionPath path, Entity entity) { | ||
final UpdateCommand command = clause.accept(VISITOR); |
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.
How come this isn't used for the RemoveClause as well?
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.
If you mean why isn't testSetClause()
used for remove? Remove doesn't use an entity. Unless you are suggesting I use Optional instead?
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's a minor nit, but it seems that you could remove the entity assertion and add it to the specific tests, or have another method call this one. This comment is minor, do what you think is best.
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 decided moving the assertion to the specific test was the cleanest.
Common PR for update expression for use by MongoDB and RocksDB implementations.