RdfGlobalResource.mapperInstance constructor

const RdfGlobalResource.mapperInstance(
  1. GlobalResourceMapper instance, {
  2. MapperDirection direction = MapperDirection.both,
})

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.

The direction parameter controls whether the mapper handles serialization, deserialization, or both. Defaults to MapperDirection.both.

Example:

// Create a pre-configured mapper with const constructor:
const bookMapper = CustomBookMapper(
  includeMetadata: true,
  defaultLanguage: 'en',
);

@RdfGlobalResource.mapperInstance(bookMapper)
class Book {
  // ...
}

// Deserialize-only mapper
@RdfGlobalResource.mapperInstance(
  bookMapper,
  direction: MapperDirection.deserializeOnly
)
class Book {
  // ...
}

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

Implementation

const RdfGlobalResource.mapperInstance(GlobalResourceMapper instance,
    {MapperDirection direction = MapperDirection.both})
    : iri = null,
      classIri = null,
      vocab = null,
      subClassOf = null,
      metadata = null,
      label = null,
      comment = null,
      fragment = null,
      super.mapperInstance(instance, direction: direction);