Repository navigation
Refactor: Simplify Config JSON binding by dropping redundant @JsonProperty names - #1602
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the configuration-deserialization simplification.
No open issues 🎉
What changed in this PR
Simplifies Config JSON deserialization by deriving property names from constructor parameters while preserving explicit mappings where JSON keys differ.
Changes:
- Removes redundant
@JsonPropertynames while retaining required-property checks. - Registers Jackson’s
ParameterNamesModulefor configuration loading. - Adds the matching Jackson dependency and enables Java’s
-parameterscompiler option.
| File | Description |
|---|---|
| application/src/main/java/org/togetherjava/tjbot/config/Config.java | Simplifies property annotations and registers parameter-name support. |
| application/build.gradle | Adds the Jackson module and preserves constructor parameter names during compilation. |
Review effort: Balanced
Tais993
left a comment
There was a problem hiding this comment.
This change should be documented in the class.
Currently, hard-coded property names make it much easier for beginners to understand how this works. If some simple Javadoc is added that explains how adding a parameter will automatically resolve its value from the config, that would be great
There was a problem hiding this comment.
im not a fan of this part:
options.compilerArgs << '-parameters'
it makes the compilation chain and the project "more complex/fragile" from a setup perspective.
but at the moment i cant say how common/problematic/heavy-weight this is. would need to do some research
|
@Tais993 FWIW, not all fields have been changed. I've kept some of them as they are (e,g: |
Spring does it in exactly the same way, using the |
Tais993
left a comment
There was a problem hiding this comment.
The code and the quality is fine. Using -parameters is alright and the usual approach.
I'm just still not sure on the direction, as I'm not sure about the actual benefit on this change. For that reason I'll let @Zabuzard make the final decision but a LGTM for now
|



Removes the explicit
valuefrom every@JsonPropertyinConfig's@JsonCreatorconstructor. Property names are now taken from the constructor parameter names.Before
After
How
application/build.gradle: compile with-parameters, addjackson-module-parameter-namesConfig: registerParameterNamesModuleon theObjectMapperconfig.jsonkey. Behavior is otherwise unchanged; existing config files load as before.