GlobalResourceMapping.mapperInstance constructor
- GlobalResourceMapper instance
Creates a reference to a directly provided mapper instance.
Use this constructor when you want to provide your own pre-configured mapper implementation rather than using the automatic generator. The mapper you provide will determine how instances of the class are mapped to RDF subjects.
This allows you to supply a pre-existing instance of a GlobalResourceMapper
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 publisherMapper = CustomPublisherMapper(
includeMetadata: true,
defaultLanguage: 'en',
);
class Book {
// Using a custom mapper for a nested Publisher object
@RdfProperty(
SchemaBook.publisher,
globalResource: GlobalResourceMapping.mapperInstance(publisherMapper)
)
final Publisher publisher;
}
Note: Since annotations in Dart must be evaluated at compile-time, the mapper instance must be a compile-time constant.
Implementation
const GlobalResourceMapping.mapperInstance(GlobalResourceMapper instance)
: super.mapperInstance(instance);