hkj-mapping

Generate compile-time, reflection-free mapping code for Java records and DTOs.

78|6|Updated Apr 4, 2025
One-click install
npx skills add https://github.com/higher-kinded-j/higher-kinded-j --skill hkj-mapping
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hkj-mapping
Source: https://github.com/higher-kinded-j/higher-kinded-j/tree/main/.claude/skills/hkj-mapping
Command: npx skills add https://github.com/higher-kinded-j/higher-kinded-j --skill hkj-mapping

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill eliminates the boilerplate and runtime risks associated with hand-written mappers, builders, and converters by generating type-safe, reflection-free, and law-checked code at compile time.

Core Features & Use Cases

  • Compile-Time Mapping: Automatically generate mapping implementations between domain records and DTOs using simple spec interfaces.
  • Validated Assembly: Construct complex records from independently validated parts while collecting every error instead of failing on the first one.
  • Sparse Updates: Handle REST PATCH requests by folding present fields into domain objects while ignoring absent ones.
  • Use Case: Replace reflective libraries like MapStruct or ModelMapper with a robust, type-safe system that ensures your domain model and wire DTOs remain perfectly synchronized.

Quick Start

Use the hkj-mapping skill to generate a mapping implementation for a domain record and its corresponding DTO by defining a spec interface that extends MappingSpec.

Frequently Asked Questions about hkj-mapping

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate compile-time Java mappings for DTOs without reflection?

Generate compile-time Java mappings for DTOs without reflection by defining a spec interface extending MappingSpec. This skill produces type-safe, law-checked mapping code automatically, eliminating runtime risks and hand-written boilerplate.

What is the best way to handle sparse PATCH updates for Java records?

Handle sparse PATCH updates for Java records by folding present fields into domain objects while ignoring absent ones. This skill generates code that safely applies partial updates to REST resources without reflective overhead.

How does validated assembly work for multi-source record merging in Java?

Validated assembly for multi-source record merging in Java constructs complex records from independently validated parts while accumulating every error. Instead of failing on the first error, it collects comprehensive validation issues across all sources.

Do I need the Higher-Kinded-J annotation processor to use law-checked mappings?

Yes, you need the Higher-Kinded-J annotation processor to use law-checked mappings. It is required to enforce type-safe boundary transitions and validate data transformations during the compile-time code generation process.

How does compile-time codegen compare to reflective libraries for Java mapping?

Compile-time codegen for Java mapping replaces reflective libraries by ensuring domain models and wire DTOs remain synchronized at build time. It enforces type-safe boundary transitions and law-checked data transformations, preventing runtime mapping failures.

Can I map multiple source records into a single Java DTO?

Map multiple source records into a single Java DTO using multi-source record merging. This skill generates code that combines independently validated parts from various sources into one target object while accumulating errors comprehensively.