RdfIri.namedMapper constructor

const RdfIri.namedMapper(
  1. String name, {
  2. MapperDirection direction = MapperDirection.both,
})

Creates a reference to a named mapper for this IRI term.

Use this constructor when you want to provide a custom IriTermMapper implementation via dependency injection. When using this approach, you must:

  1. Implement the mapper yourself
  2. Instantiate the mapper (outside of the generated code)
  3. Provide the mapper instance as a named parameter to initRdfMapper

The name will be used as a parameter name in the generated initRdfMapper function.

This approach is particularly useful for IRIs that require complex logic or external context (like base URLs) that might vary between deployments.

Example:

@RdfIri.namedMapper('userReferenceMapper')
class UserReference {
  final String username;
  UserReference(this.username);
}

// You must implement the mapper:
class MyUserReferenceMapper implements IriTermMapper<UserReference> {
  // Your implementation...
}

// In initialization code:
final userRefMapper = MyUserReferenceMapper();
final rdfMapper = initRdfMapper(userReferenceMapper: userRefMapper);

Implementation

const RdfIri.namedMapper(String name, {super.direction})
    : template = null,
      fragmentTemplate = null,
      super.namedMapper(name);