RDF Mapper Generator

Code generation for zero-boilerplate RDF mapping.
Transform annotations into optimized, type-safe mapper code.

locorda_rdf_mapper_generator is a build_runner plugin that processes annotations to generate optimized mapping code at build time. No runtime reflection, no boilerplate, just pure generated performance.

See the full mapper guide for complete examples and getting started instructions.

How It Works

1

Annotate Your Classes

Add RDF mapping annotations to your domain model.

@RdfGlobalResource(
  SchemaBook.classIri,
  IriStrategy('https://example.org/books/{isbn}'),
)
class Book { ... }
2

Run Build Runner

Execute the code generator to create mappers.

dart run build_runner build --delete-conflicting-outputs
3

Use Generated Mappers

Initialize and use type-safe mappers automatically.

final mapper = initRdfMapper();
final turtle = mapper.encodeObject(book);
final book = mapper.decodeObject<Book>(turtle);

What Gets Generated

πŸ“„ Main Initialization File

init_rdf_mapper.g.dart

Central initialization function that registers all mappers and automatically requires any dependencies from your annotations (providers, custom mappers, etc.).

πŸ”§ Individual Mapper Files

*.rdf_mapper.g.dart

One mapper file per annotated class with optimized serialization/deserialization code.

⚑ Optimized IRI Parsing

Regex-based pattern matching

Efficient IRI parsing with pre-compiled regular expressions for template strategies.

πŸ›‘οΈ Type-Safe Mapping

Full compile-time guarantees

Generated code is strongly typed with null safety throughout.

Generator Features

πŸ”₯ Zero Boilerplate

Write domain models, not serialization code. The generator handles all the tedious mapping logic.

⚑ Zero Runtime Overhead

All mapping logic is generated at compile time. No reflection, no runtime analysis.

🌳 Tree-Shakeable

Only the mappers you actually use are included in your final build.

πŸ›‘οΈ Type Safety

Compile-time validation of all mappings. Catch errors before runtime.

πŸ”§ Smart Defaults

Intelligent default value handling and null safety throughout.

πŸ“¦ Collection Inference

Automatic detection and handling of List, Set, Map types.

Development Workflow

✏️

1. Annotate Classes

Add RDF mapping annotations to your domain model classes.

βš™οΈ

2. Run Generator

Execute dart run build_runner build to generate mappers.

πŸ§ͺ

3. Test & Iterate

Test your mappers, adjust annotations, re-run generator as needed.

πŸš€

4. Ship

Generated code is optimized and ready for production.

Ready to Generate?

Go back to the full guide or explore the API docs.