RdfLocalResource.namedMapper constructor
const
RdfLocalResource.namedMapper(
- String name, {
- MapperDirection direction = MapperDirection.both,
Creates a reference to a named mapper for this local resource.
Use this constructor when you want to provide a custom LocalResourceMapper
implementation via dependency injection. When using this approach, you must:
- Implement the mapper yourself
- Instantiate the mapper (outside of the generated code)
- Provide the mapper instance as a named parameter to
initRdfMapper
The name will correspond to a parameter in the generated initRdfMapper function,
but the mapper will not be registered globally in the RdfMapper instance
but only used for the Resource Mapper whose property is annotated with this mapping.
Example:
class Book {
// Using a custom mapper for a nested Chapter object
@RdfProperty(
SchemaBook.chapter,
localResource: LocalResourceMapping.namedMapper('customChapterMapper')
)
final Chapter chapter;
}
// You must implement the mapper:
class MyChapterMapper implements LocalResourceMapper<Chapter> {
// Your implementation...
}
// In initialization code:
final chapterMapper = MyChapterMapper();
final rdfMapper = initRdfMapper(customChapterMapper: chapterMapper);
Implementation
const RdfLocalResource.namedMapper(String name, {super.direction})
: classIri = null,
super.namedMapper(name);