GlobalResourceMapping.mapper constructor
const
GlobalResourceMapping.mapper(
- 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 GlobalResourceMapper<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 Publisher object
@RdfProperty(
SchemaBook.publisher,
globalResource: GlobalResourceMapping.mapper(CustomPublisherMapper)
)
final Publisher publisher;
}
// The mapper implementation must be accessible to the generator and
// it must provide a no-argument constructor:
class CustomPublisherMapper implements GlobalResourceMapper<Publisher> {
// Implementation details...
}
Implementation
const GlobalResourceMapping.mapper(Type mapperType)
: super.mapper(mapperType);