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
Annotate Your Classes
Add RDF mapping annotations to your domain model.
@RdfGlobalResource(
SchemaBook.classIri,
IriStrategy('https://example.org/books/{isbn}'),
)
class Book { ... } Run Build Runner
Execute the code generator to create mappers.
dart run build_runner build --delete-conflicting-outputs 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.