What problem does it solve?
This Skill enforces compile-time safety for MapStruct mappings by using constructor-based mapping and a default-constructor annotation pattern, preventing runtime surprises when constructors change.
Core Features & Use Cases
- Constructor-based mapping discipline: MapStruct binds to a constructor signature, causing compilation errors if signatures change, ensuring stability.
- Custom @Default pattern: Demonstrates selecting a preferred constructor via a user-defined annotation to drive mapping behavior.
- CDI and records support: Shows CDI integration and how Java Records map naturally with constructor-based approaches.
- Compile-time safety benefits: Highlights how updates to constructors require mapper changes to compile, reducing drift between model and DTOs.
- ** Cookbook reference patterns**: Provides starter patterns for entity mapping, record mapping, and related scenarios.
Quick Start
Create a CDI-based MapStruct mapper for an entity using a Default constructor annotation to guide the selected constructor and ensure compile-time safety.