Skip to content

Commit ec9a83a

Browse files
committed
Merge worktree-fr006-java-complete-2026-05-27 — Java payload-VO codegen complete (all template subtypes + origin.* resolution)
2 parents 99d5e39 + 3e8d96d commit ec9a83a

4 files changed

Lines changed: 635 additions & 90 deletions

File tree

docs/features/templates-and-payloads.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,25 +208,34 @@ const out: string = await render({
208208
### Java
209209

210210
`metaobjects-render` ships `Renderer` + `Provider` (Classpath, Filesystem,
211-
InMemory) + `Verify`. Payload-VO codegen is **not** shipped on the Java side — host
212-
code consumes the payload as a Java `Map<String,Object>` or a hand-coded value
213-
object.
211+
InMemory) + `Verify`. `SpringPayloadGenerator` (in `metaobjects-codegen-spring`)
212+
emits a Java 21 `record` payload per template, resolving all three origin
213+
subtypes (matches the Kotlin reference). Host code may also pass a
214+
`Map<String,Object>` to the renderer if it doesn't want the generated type.
214215

215216
```java
216217
import com.metaobjects.render.*;
217218
218219
Provider provider = new FilesystemProvider(Path.of("./prompts"));
219220
String out = Renderer.render(RenderRequest.builder()
220221
.ref("lobby/welcome")
221-
.payload(Map.of(
222-
"displayName", "Ada",
223-
"postCount", 12L,
224-
"posts", List.of(Map.of("title", "Hello"))))
222+
.payload(new WelcomePayload("Ada", 12L, List.of(new PostSummary("Hello"))))
225223
.provider(provider)
226224
.format("xml")
227225
.build());
228226
```
229227

228+
```java
229+
// generated/acme/blog/prompts/WelcomePromptPayload.java
230+
public record WelcomePromptPayload(
231+
String displayName,
232+
Long postCount,
233+
java.util.List<PostSummary> posts
234+
) {}
235+
236+
public record PostSummary(String title) {}
237+
```
238+
230239
### Kotlin
231240

232241
`metaobjects-metadata-ktx` wraps `Renderer` in an idiomatic Kotlin builder.

server/java/codegen-spring/src/main/java/com/metaobjects/generator/spring/KNOWN_GAPS.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,37 +38,6 @@ needs either `Optional<T>` arms (verbose) or a builder + nullable
3838
representation, neither of which is a one-liner. A follow-up can add
3939
these once the partial-update story is settled cross-port.
4040

41-
## Payload `origin.*` resolution not honoured (FR-006, Day-1)
42-
43-
**Status:** intentional Day-1 simplification.
44-
45-
`SpringPayloadGenerator` emits a `<TemplateShortName>Payload` Java record
46-
with components mirroring the `@payloadRef` value-object's scalar fields,
47-
using `SpringTypeMapper.javaTypeName` for type resolution. `origin.*`
48-
children on payload fields (passthrough / aggregate / collection) are
49-
NOT yet honoured — each field's type comes from its own subtype, not
50-
from the dotted source it references.
51-
52-
The cross-port reference (Kotlin's `KotlinPayloadGenerator`) resolves
53-
these:
54-
- `origin.passthrough @from "Entity.field"` → source field's type
55-
- `origin.aggregate @agg count``Long`; `@agg avg``Double`;
56-
`sum/min/max` → source `@of` field's type
57-
- `origin.collection @via "Parent.rel"``List<TargetPayload>` (recurses
58-
into a nested payload class)
59-
60-
**Why deferred:** the cross-port `template-output-simple` and
61-
`template-output-and-prompt` corpus fixtures both use plain VO field
62-
projection (no origins), so payload codegen is honest at the
63-
straightforward fixture level. Origin support is tracked here as a
64-
follow-up so a future entity-projection consumer who needs it has a
65-
clear known-gap rather than a silent type mismatch.
66-
67-
**Workaround:** consumers needing typed origin-driven payloads today can
68-
hand-edit the generated record's field types. The `GENERATED` banner is
69-
advisory — regeneration overwrites, so the hand-edit needs to be
70-
preserved out-of-band until origin resolution lands.
71-
7241
## Output parser is throw-only (no try-style variant)
7342

7443
**Status:** by design, per ADR-0010 §3.

0 commit comments

Comments
 (0)