Commit 5bc784d
authored
Constructor parser upgrades (#16)
* Constructor-based parsing follow-ups
- Honor @JsonIgnore consistently across analyzer, validator, and generator
(collapses four drifting field-skip predicates into a single
ConstructorAnalyzer.getParseableFields).
- Match generic constructor parameter types: List<String> now resolves to
reflection's raw List, fixing immutable POJOs with generic-typed
constructor parameters silently failing constructor matching.
- Use field names for constructor-bound locals so sibling fields don't
collide on level-based names (threaded through Collection, Map,
PrimitiveArray, CustomObject, Enum, Simple parsers; legacy setter-based
output stays byte-identical).
- Allow user Map subclasses (class FooMap extends HashMap<K,V>) to dispatch
to a custom parser by simple name, while keeping JDK Map types excluded
so raw Map fields don't route to a non-existent MapParser.
- Bump version to 1.1.1-SNAPSHOT.
* Test new constructor-based parsing behaviors via t1-t3 pipeline
Adds two new immutable POJO fixtures wired into TestRootObjectType so the
t1 (expected roundtrip), t2 (generated-vs-expected), and t3 (generated
roundtrip) scripts all exercise the new behaviors:
- TestConstructorWithGenericsType — constructor params List<String>,
Map<String,Integer>, Set<String>, int[], String[]. Covers stripGenerics
matching plus the variableName overrides on CollectionFieldParser,
MapFieldParser, and PrimitiveArrayFieldParser.
- TestConstructorWithIgnoredFieldType — final @JsonIgnore field that is
NOT a constructor parameter (derived from another). Covers
getParseableFields skipping @JsonIgnore on the constructor-based path
so the single-arg constructor matches the single parseable field.
Plus a focused unit test CustomObjectFieldParserTest for the isJdkMap
guard (raw java.util Maps don't route to a non-existent parser; user
Map subclasses still pass through).
* Support Java records in constructor-based parsing
- Detect clazz.isRecord() and use getRecordComponents() instead of source-file parsing
- Skip validateGetterSetter shape check for records (bare x() accessors)
- Add TestRecordType fixture wired into TestRootObjectType for t1-t3 coverage
* Extract local-variable name resolution into ParserCommonUtils.localVarName
Replaces the variableName != null ? ... : getVariableNameForLevel(...) ternary
duplicated 17 times across the collection/map/primitive-array parsers.1 parent f0d7a30 commit 5bc784d
22 files changed
Lines changed: 662 additions & 148 deletions
File tree
- gwt-beans-codegen-core/src
- main/java/nl/aerius/codegen
- analyzer
- generator
- parser
- validator
- test
- java/nl/aerius/codegen
- analyzer
- generator/parser
- test/types
- resources/parsers/expected
Lines changed: 44 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| |||
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
| |||
159 | 168 | | |
160 | 169 | | |
161 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
162 | 190 | | |
163 | 191 | | |
164 | 192 | | |
| |||
231 | 259 | | |
232 | 260 | | |
233 | 261 | | |
234 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
235 | 265 | | |
236 | 266 | | |
237 | 267 | | |
238 | 268 | | |
239 | | - | |
240 | | - | |
241 | | - | |
| 269 | + | |
242 | 270 | | |
243 | 271 | | |
244 | 272 | | |
245 | 273 | | |
246 | 274 | | |
247 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
248 | 283 | | |
249 | 284 | | |
250 | 285 | | |
| |||
301 | 336 | | |
302 | 337 | | |
303 | 338 | | |
304 | | - | |
| 339 | + | |
| 340 | + | |
305 | 341 | | |
306 | 342 | | |
307 | | - | |
308 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
309 | 346 | | |
310 | 347 | | |
311 | 348 | | |
| |||
Lines changed: 5 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
170 | 167 | | |
171 | 168 | | |
172 | 169 | | |
| |||
Lines changed: 31 additions & 62 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 251 | + | |
256 | 252 | | |
257 | 253 | | |
258 | 254 | | |
259 | 255 | | |
260 | | - | |
261 | 256 | | |
262 | 257 | | |
263 | 258 | | |
| |||
376 | 371 | | |
377 | 372 | | |
378 | 373 | | |
379 | | - | |
| 374 | + | |
380 | 375 | | |
381 | 376 | | |
382 | 377 | | |
| |||
439 | 434 | | |
440 | 435 | | |
441 | 436 | | |
442 | | - | |
| 437 | + | |
443 | 438 | | |
444 | 439 | | |
445 | 440 | | |
| |||
458 | 453 | | |
459 | 454 | | |
460 | 455 | | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
511 | 480 | | |
512 | 481 | | |
513 | 482 | | |
| |||
0 commit comments