Skip to content

Java target

Use the Java target for JVM consumers that need generated model classes with JSON and YAML helper behavior.

emit-targets:
- type: Java
output-dir: "generated/java"
test-dir: "generated/java/tests"
package-name: "typra.fixtures"
protocol-scaffolds: "compile-only"
native-serialization: "jackson"
OptionWhy it matters
output-dirWhere generated Java source is written.
test-dirWhere generated Java tests are written.
package-nameJava package for generated classes.
protocol-scaffoldsEmits compile-only test scaffolds for generated protocols.
native-serializationDefaults to "none". Set to "jackson" to emit Jackson serializers and deserializers that delegate to Typra load/save.

Generated Java surfaces include models with load, save, fromJson, toJson, fromYaml, toYaml, scalar coercion, enum handling, polymorphic dispatch, tests, and optional Jackson interop.

import typra.fixtures.FixtureRoot;
FixtureRoot root = FixtureRoot.fromJson(jsonText);
String saved = root.toJson();
FixtureRoot yamlRoot = FixtureRoot.fromYaml(yamlText);
String yamlSaved = yamlRoot.toYaml();

Confirm package layout and generated API shape before publishing Java output for downstream consumers.

native-serialization: "jackson" adds Jackson annotations plus generated serializer/deserializer classes. The emitter does not edit a consumer build manifest, so projects enabling this option must provide jackson-databind on their Java compile/runtime classpath.