RdfIri.mapperInstance constructor

const RdfIri.mapperInstance(
  1. IriTermMapper instance, {
  2. MapperDirection direction = MapperDirection.both,
})

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.

Example:

// Create a pre-configured mapper with const constructor:
const catalogMapper = ProductCatalogMapper(
  baseUrl: 'https://shop.example.org/catalog/',
  format: UriFormat.pretty,
);

@RdfIri.mapperInstance(catalogMapper)
class ProductReference {
  final String sku;
  ProductReference(this.sku);
}

Note: Since annotations in Dart must be evaluated at compile-time, the mapper instance must be a compile-time constant.

Implementation

const RdfIri.mapperInstance(IriTermMapper instance, {super.direction})
    : template = null,
      fragmentTemplate = null,
      super.mapperInstance(instance);