Skip to content

Improved consistency in writing Util classes and removed raw types to make types more stable #3408

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

Closed
wants to merge 7 commits into from

Conversation

ch4570
Copy link

@ch4570 ch4570 commented Mar 24, 2024

Hello.
I've been putting your Spring Data JPA to good use in my practice.

I've modified & improved the code of a few classes to create a PR and upload it.
Below are the classes I worked on and the reasons for the changes.

  • PageableUtils.java
    The abstract keyword is used to emphasize that the utility class does not need to be instantiated.

  • Meta.java
    We changed values in the Meta class because it is a private field that is only used internally and it is better to initialize it with a LinkedHashMap beforehand instead of checking if the element is empty every time setValue is called and initializing it with a LinkedHashMap.

  • NamedQuery.java
    Since EntityManager implements the AutoCloseable interface, it is better to use try-with-resources rather than explicitly calling close in the finally block after using resources, so we modified the code.

  • JsqlParserUtils.java
    Since the JSqlPaserUtils class is also a Util class, we clarified the semantics with the abstract keyword and modified the private constructor to throw the same exception to be consistent with PageableUtils.

The getJsqlCount and getJsqlLower methods are using ExpressionList as a raw type, but ExpressionList only allows classes that implement the Expression interface, and the withParameters method of Function class is only used by JsqlParserUtils, so we changed it to a type-safe code that uses Generic.

서민재 and others added 7 commits October 29, 2023 21:28
…wing logic to private constructor, improved ExpressionList Raw Type usage to use generics
…tatement for EntityManager used within the hasNamedQuery method of the NamedQuery class.
…it's not a class you use by creating instances of it
…class Constant class that cannot be inherited."

This reverts commit c872085.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 24, 2024
@mp911de mp911de added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 15, 2024
@christophstrobl
Copy link
Member

Thank you @ch4570.

@ch4570
Copy link
Author

ch4570 commented Apr 22, 2024

@christophstrobl Thank you for merging my PR.
I'm wondering why I don't see any contributor indication when the code is merged into the main branch.

@christophstrobl
Copy link
Member

christophstrobl commented Apr 22, 2024

@ch4570 Thank you for the contribution - I'm sorry about that. The email used does not seem to be linked to your account (like in this commit c872085 from the original PR).

@christophstrobl christophstrobl added this to the 3.3 GA (2024.0.0) milestone Apr 22, 2024
@ch4570
Copy link
Author

ch4570 commented Apr 22, 2024

@christophstrobl I didn't realize I had a different username because I committed from work.
I apologize for bothering you with this question.

Thank you for your kind response.
I'll try to contribute more in the future. 🥇

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

Successfully merging this pull request may close these issues.

4 participants