Editions Mappers Use Cases Documentation Community Download Get Started →
Use Cases

What teams build with TwinMapper

From document binding to layer-to-layer mapping to full schema-driven code generation — see how TwinMapper replaces fragmented toolchains with a single compile-time platform.

Use Case 01

Document Binding

Bind YAML, JSON, and BPMN XML runtime documents into strongly typed generated DTOs. The NodeCursor abstraction provides format-neutral traversal — generated binders have zero dependency on Jackson, SnakeYAML, or StAX directly.

Replace hand-written deserialization, manual field mapping, and scattered @JsonProperty annotations with a single definition file that drives the entire binding pipeline.

  • Alias-aware field reading with fallback resolution
  • Default value population and required-field enforcement
  • Strict unknown-field rejection mode
  • Nested object, collection, and map binding
  • BindingResult carries errors without throwing
Use Case 02

Layer-to-Layer Object Mapping

Generate typed Java-to-Java mappers for every architectural boundary: entity↔domain, domain↔DTO, DTO↔entity, entity↔projection, request/command↔domain, and domain↔event/view/response.

Three mapper modes address different lifecycle stages: CREATE builds new targets, UPDATE applies changes with configurable null policy, and PATCH applies only non-null fields.

  • Field renaming, nested property paths, flattening, expansion
  • Value object conversion and enum/code translation
  • Inverse mapper generation from the same definition
  • Profile-based conditional mapping
  • Proxy-safe via AopUtils on Spring-managed beans
Use Case 03

Schema-Driven Code Generation

Write one YAML definition; get DTOs, enums, binders, validators, registries, metadata descriptors, and object mappers. The five-stage pipeline (Validate → Plan → Generate → Customize → Render) is fully deterministic — identical inputs always produce identical outputs.

Replace jsonschema2pojo for DTO generation, eliminate hand-written mapper boilerplate, and unify your binding and mapping toolchain.

  • 11 specialized generators: DTO, Enum, Binder, Validator, Metadata, 3 Mapper modes, Inverse, 2 Registries
  • CodegenCustomizer SPI for controlled modification before rendering
  • Render-only pipeline — no filesystem writes during generation
  • Request-level atomicity across all generated artifacts
Use Case 04

BPMN Document Processing

Parse BPMN XML process definitions into typed Java models without any process engine dependency. TwinMapper uses JDK StAX directly — no Camunda, no Flowable, no vendor lock-in.

BPMN is treated as an authoring format, not a workflow engine. Definitions are parsed into the canonical meta-model and feed the same code generation pipeline as YAML and JSON.

  • XXE-safe XMLInputFactory configuration by default
  • BpmnIntermediateModel → NodeCursor adapter
  • ResourceLoader-based classpath resolution
  • Same binding and validation pipeline as YAML/JSON
Use Case 05

Replacing MapStruct, ModelMapper, and jsonschema2pojo

TwinMapper unifies capabilities that previously required assembling three separate tools. MapStruct handles object mapping; jsonschema2pojo handles DTO generation; Jackson/SnakeYAML handle parsing. TwinMapper provides all three from a single definition source.

  • MapStruct replacement: all of MapStruct's compile-time object mapping, plus document binding and BPMN
  • ModelMapper replacement: compile-time generation instead of runtime reflection
  • jsonschema2pojo replacement: Spring-native DTOs with binders, validators, and metadata
  • Migration guides available for Dozer and Orika legacy codebases