IriStrategy.mapperInstance constructor
- IriTermMapper instance, {
- String? providedAs,
Creates a reference to a directly provided mapper instance for this IRI term.
This allows you to directly provide a pre-configured IriTermMapper instance
that works with a record type composed of the values from properties marked
with @RdfIriPart. Unlike RdfIri and IriMapping which work with whole objects,
IriStrategy mappers must work with records of property values.
For multiple IRI parts, use @RdfIriPart.position(index) to specify the order
of each property in the record:
// Create a pre-configured mapper for a record type:
const productMapper = CustomProductMapper(
baseUrl: 'https://shop.example.org/catalog/',
format: UriFormat.pretty,
);
@RdfGlobalResource(Product.classIri, IriStrategy.mapperInstance(productMapper))
class Product {
// First field in the record passed to productMapper
@RdfIriPart.position(0)
final String category;
// Second field in the record passed to productMapper
@RdfIriPart.position(1)
final String sku;
// ...
}
Note: Since annotations in Dart must be evaluated at compile-time, the mapper instance must be a compile-time constant.
The optional providedAs parameter allows this resource's IRI to be provided to dependent
mappers under the specified name, enabling hierarchical IRI patterns.
Implementation
const IriStrategy.mapperInstance(IriTermMapper instance, {this.providedAs})
: template = null,
fragmentTemplate = null,
super.mapperInstance(instance);