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

Visitor for UpdateClause class hierarchy #21

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

stevelorddremio
Copy link
Owner

Common PR for update expression for use by MongoDB and RocksDB implementations.

* @return the possibly transformed value resulting from the visitation.
*/
default <T> T accept(UpdateClauseVisitor<T> visitor) {
throw new IllegalArgumentException();
Copy link
Collaborator

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.

Copy link
Owner Author

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 {
Copy link
Collaborator

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?

Copy link
Owner Author

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.

Copy link

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?

Copy link
Owner Author

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);
Copy link
Collaborator

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?

Copy link
Owner Author

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?

Copy link

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.

Copy link
Owner Author

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.

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

Successfully merging this pull request may close these issues.

3 participants