LocalResourceMapping.mapperInstance constructor
const
LocalResourceMapping.mapperInstance(
- LocalResourceMapper instance
Creates a reference to a directly provided mapper instance for this local resource.
This allows you to supply a pre-existing instance of a LocalResourceMapper
for this class. Useful when your mapper requires constructor parameters
or complex setup that cannot be handled by simple instantiation.
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 chapterMapper = CustomChapterMapper(
validation: strictValidation,
options: chapterOptions,
);
class Book {
// Using a custom mapper for a nested Chapter object
@RdfProperty(
SchemaBook.chapter,
localResource: LocalResourceMapping.mapperInstance(chapterMapper)
)
final Chapter chapter;
}
Note: Since annotations in Dart must be evaluated at compile-time, the mapper instance must be a compile-time constant.
Implementation
const LocalResourceMapping.mapperInstance(LocalResourceMapper instance)
: super.mapperInstance(instance);