IriMapping.mapperInstance constructor
const
IriMapping.mapperInstance(
- IriTermMapper instance
Creates a reference to a directly provided mapper instance for this IRI term.
This allows you to directly provide a pre-configured IriTermMapper instance
to handle mapping for this class without dependency injection.
This approach is ideal when your mapper requires configuration that must be provided at initialization time, such as base URLs or formatting parameters.
It will only be used for the Resource Mapper whose property is annotated with this mapping, not automatically be registered globally.
Example:
// Create a pre-configured mapper with const constructor:
const catalogMapper = ProductCatalogMapper(
baseUrl: 'https://shop.example.org/catalog/',
format: UriFormat.pretty,
);
class Book {
// Using a custom pre-configured mapper for a product reference
@RdfProperty(
Schema.product,
iri: IriMapping.mapperInstance(catalogMapper)
)
final ProductReference product;
}
Note: Since annotations in Dart must be evaluated at compile-time, the mapper instance must be a compile-time constant.
Implementation
const IriMapping.mapperInstance(IriTermMapper instance)
: template = null,
fragmentTemplate = null,
super.mapperInstance(instance);