BaseMapping<M>.mapperInstance constructor

const BaseMapping<M>.mapperInstance(
  1. M instance
)

Creates a reference to a directly provided mapper instance.

This allows you to supply a pre-configured mapper instance to handle mapping for this type. Useful when your mapper requires constructor parameters or complex setup that cannot be handled by simple instantiation.

Since Dart annotations must be compile-time constants, the mapper instance must be a const instance. If it cannot be const, consider using BaseMapping.namedMapper instead.

Example:

// Create a pre-configured mapper with const constructor:
const myPriceMapper = PriceMapper(
  currency: 'EUR',
  locale: 'de_DE',
);

@RdfProperty(
  SchemaBook.price,
  literal: LiteralMapping.mapperInstance(myPriceMapper)
)
final Price price;

Implementation

const BaseMapping.mapperInstance(M instance)
    : _mapperName = null,
      _mapperType = null,
      _mapperInstance = instance,
      _factoryName = null,
      _factoryConfigInstance = null;