RdfGlobalResource.mapper constructor

const RdfGlobalResource.mapper(
  1. Type mapperType, {
  2. MapperDirection direction = MapperDirection.both,
})

Creates a reference to a mapper that will be instantiated from the given type.

Use this constructor when you want to provide your own custom mapper implementation rather than using the automatic generator. The mapper you provide will determine how instances of the class are mapped to RDF subjects.

The generator will create an instance of mapperType to handle mapping for instances of this class. The type must implement GlobalResourceMapper<T> where T is the annotated class.

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

Note: The mapper will be registered globally in the RdfMapper instance. If you need non-global registration, do not annotate your class with @RdfGlobalResource.

Example:

@RdfGlobalResource.mapper(CustomBookMapper)
class Book {
  // ...
}

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

// The mapper implementation must be accessible to the generator and
// it must provide a no-argument constructor:
class CustomBookMapper implements GlobalResourceMapper<Book> {
  // Implementation details...
}

Implementation

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