Make Utility Class constructor private to enforce noninstantiability
Description
This PR modifies the LettuceClassUtils, ReplicaUtils, ReflectionTestUtils class to enforce noninstantiability by changing its constructor to private, aligning with Java best practices for utility classes (Effective Java, Item 4). Additionally, Javadoc is added to clarify the class's purpose and prevent misuse. Similar utility classes were reviewed to ensure consistency.
Key changes:
- Changed
LettuceClassUtils,ReplicaUtils,ReflectionTestUtilsconstructor toprivateto prevent instantiation. - No functional changes; maintains backward compatibility.
Related Issue
Closes #3265
Checklist
- [x] I have read the contribution guidelines.
- [x] I have created a feature request first to discuss my contribution intent. See #3265
- [x] I applied code formatting rules using the
mvn formatter:formattarget. No formatting-related changes were submitted. - [x] I have submitted test cases (unit or integration tests) to back my changes, where applicable.
Additional Notes
- Testing: No functional changes were made, so existing tests remain valid. Added a test to verify that
LettuceClassUtilscannot be instantiated. - Impact: This change is internal and does not affect the public API or user-facing behavior.
- Build Fix: Ensured compliance with
formatter-maven-pluginby runningmvn formatter:formatandmvn formatter:validate.
I don't disagree with the change, but I think we can only accept it for a major release.
If somebody already uses these classes by instantiating them (which I agree is wrong, but would still work) we would break their code. So we need to target something other than a minor/patch release.