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

feat: Allow direct rendering of Visitable objects. #554

Merged
merged 5 commits into from
Jan 13, 2023
Merged

Conversation

michael-simons
Copy link
Collaborator

This changes the org.neo4j.cypherdsl.core.renderer.Renderer#render method to accept any Visitable so that an intermediate representation can be retrieved.

Reluctant use is suggested, as the intermediate representation won't be cached in the renderer.

In addition, an overload of toString has been added to many Visitable types. While I would liked to have added this to the Visitable interface as suggested by @lukaseder, this is not possible as specified in the JLS 9.4.1.2. "Requirements in Overriding" (https://docs.oracle.com/javase/specs/jls/se17/html/jls-9.html#jls-9.4.1.2) (more background here https://mail.openjdk.org/pipermail/lambda-dev/2013-March/008435.html)

Closes #552.

This changes the `org.neo4j.cypherdsl.core.renderer.Renderer#render` method to accept any `Visitable` so that an intermediate representation can be retrieved.

Reluctant use is suggested, as the intermediate representation won't be cached in the renderer.

In addition, an overload of `toString` has been added to many `Visitable` types. While I would liked to have added this to the `Visitable` interface as suggested by @lukaseder, this is not possible as specified in the JLS 9.4.1.2. "Requirements in Overriding" (https://docs.oracle.com/javase/specs/jls/se17/html/jls-9.html#jls-9.4.1.2) (more background here https://mail.openjdk.org/pipermail/lambda-dev/2013-March/008435.html)

Closes #552.
@lukaseder
Copy link

While I would liked to have added this to the Visitable interface as suggested by @lukaseder

I assumed there was some base class for all Visitable types for such things. May have been too lazy to phrase that correctly 😅

… to correctly quote the error message and commit everything.
@lukaseder
Copy link

Note, you can still re-declare the method (keeping it abstract) in order to add some Javadoc, e.g. what you mentioned in the commit: 3fb7fb7

Reluctant use is suggested, as the intermediate representation won't be cached in the renderer.

@michael-simons
Copy link
Collaborator Author

Oh that's a good hint, thank you!

@michael-simons
Copy link
Collaborator Author

Re abstract base clase: Yes, a major refactoring of the general structure is due, see #550. This project grew quite a bit since it's inception as an internal Spring Data module.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

81.0% 81.0% Coverage
0.0% 0.0% Duplication

@michael-simons michael-simons merged commit d743bd3 into main Jan 13, 2023
@michael-simons michael-simons deleted the issue/552 branch January 13, 2023 16:06
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.

Implement Visitable.toString() with accept(prettyPrintingVisitor)
2 participants