GlobalResourceMapping.namedMapper constructor
const
GlobalResourceMapping.namedMapper(
- String name
Creates a reference to a named mapper that will be injected at runtime.
Use this constructor when you want to provide your own custom
GlobalResourceMapper implementation rather than using the automatic generator.
The mapper you provide will determine how instances of the class are mapped to
RDF subjects. 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 Publisher object
@RdfProperty(
SchemaBook.publisher,
globalResource: GlobalResourceMapping.namedMapper('customPublisherMapper')
)
final Publisher publisher;
}
// You must implement the mapper:
class MyPublisherMapper implements GlobalResourceMapper<Publisher> {
// Your implementation...
}
// In initialization code:
final publisherMapper = MyPublisherMapper();
final rdfMapper = initRdfMapper(customPublisherMapper: publisherMapper);
Implementation
const GlobalResourceMapping.namedMapper(String name)
: super.namedMapper(name);