LocalResourceMapping.mapper constructor

const LocalResourceMapping.mapper(
  1. Type mapperType
)

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 LocalResourceMapper<T> where T is the annotated class and it must have a no-argument default constructor. It will only be used for the Resource Mapper whose property is annotated with this mapping, not automatically be registered globally.

Example:

class Book {
  // Using a custom mapper for a nested Chapter object
  @RdfProperty(
    SchemaBook.chapter,
    localResource: LocalResourceMapping.mapper(CustomChapterMapper)
  )
  final Chapter chapter;
}

// The mapper implementation must be accessible to the generator:
class CustomChapterMapper implements LocalResourceMapper<Chapter> {
  // Implementation details...
}

Implementation

const LocalResourceMapping.mapper(Type mapperType) : super.mapper(mapperType);