RdfLiteral.namedMapper constructor
const
RdfLiteral.namedMapper(
- String name, {
- MapperDirection direction = MapperDirection.both,
Creates a reference to a named mapper for this literal term.
Use this constructor when you want to provide a custom LiteralTermMapper
implementation via dependency injection. When using this approach, you must:
- Implement the mapper yourself
- Instantiate the mapper (outside of the generated code)
- Provide the mapper instance as a named parameter to
initRdfMapper
The name will correspond to a parameter in the generated initRdfMapper
function.
This approach is particularly useful for complex value objects that require special serialization logic or context-dependent conversions.
Example:
@RdfLiteral.namedMapper('temperatureMapper')
class Temperature {
final double celsius;
Temperature(this.celsius);
// ...
}
// You must implement the mapper:
class MyTemperatureMapper implements LiteralTermMapper<Temperature> {
// Your implementation...
}
// In initialization code:
final tempMapper = MyTemperatureMapper();
final rdfMapper = initRdfMapper(temperatureMapper: tempMapper);
Implementation
const RdfLiteral.namedMapper(String name, {super.direction})
: toLiteralTermMethod = null,
fromLiteralTermMethod = null,
datatype = null,
super.namedMapper(name);