Commit 547c698
feat(#195): Java per-capability origin validation + native typing (cross-port parity)
Mirrors the committed TS reference (63943d0 validation, aff49ce typing) into the Java port.
- ExpressionAttribute.java: the closed expression-node grammar as validateExprNode
(structural, fail-closed) + inferExprType (entity-aware, bottom-up) over the verbatim
Map tree, reusing FilterOps for the shared op vocabulary + per-subtype legality bands
(mirrors TS keeping the grammar beside the attr, not in validateValue).
- ValidationPhase.java: the per-capability rules in validateOriginNode — any/all (boolean
non-array; @filter required; @Of forbidden; @via required + to-many), collect (isArray;
@Of required + #185 element-type preservation; @distinct/@orderby collect-only + mutually
exclusive; @orderby resolves on @Of), the inverse rule, origin.computed (grammar →
ERR_UNKNOWN_EXPR_NODE; inference vs base effective fields; mismatch → ERR_COMPUTED_TYPE_MISMATCH),
origin.first (@Of required + type-preserving; not @required; @via inference; @orderby) —
reusing the existing origin-path helpers.
- ErrorCode.java: ERR_UNKNOWN_EXPR_NODE + ERR_COMPUTED_TYPE_MISMATCH.
- SpringDtoGenerator.java: originGuaranteedNonNull → @NotNull on any/all/collect DTO
components; first + computed stay nullable.
- OriginCapabilityValidationTest.java (new): 20 tests mirroring the TS suite.
Verified: mvn -pl metadata test 1161 run / 0 fail (incl. the 20 + the 3 #195 fixtures +
registry-conformance); codegen-spring 168 / 0 (incl. a real-javac DTO compile-run). Error
CODES identical to TS. Divergence (behavioral parity holds): Java validation is eager-throw
vs TS accumulate-all — same inputs accepted/rejected, only simultaneous-error count differs;
rule ordering matches so the first-thrown equals the TS-targeted error.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGQ7oSuNcjhsMHWwZzhBwr1 parent 845b8cf commit 547c698
6 files changed
Lines changed: 1028 additions & 13 deletions
File tree
- server/java
- codegen-spring/src
- main/java/com/metaobjects/generator/spring
- test/java/com/metaobjects/generator/spring
- metadata/src
- main/java/com/metaobjects
- attr
- loader
- test/java/com/metaobjects/loader
Lines changed: 32 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
634 | 636 | | |
635 | 637 | | |
636 | 638 | | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
637 | 664 | | |
638 | 665 | | |
639 | 666 | | |
| |||
667 | 694 | | |
668 | 695 | | |
669 | 696 | | |
670 | | - | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
671 | 702 | | |
672 | 703 | | |
673 | 704 | | |
| |||
Lines changed: 83 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
153 | 236 | | |
154 | 237 | | |
155 | 238 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
367 | 385 | | |
368 | 386 | | |
369 | 387 | | |
0 commit comments