iri property
Specifies how to treat the property's value as an IRI reference.
Use this when the property's value represents an IRI (e.g., a URL) or when you need to override the default literal mapping for a type.
Only needed when there is no IriMapper already registered globally for the property value's type, or when you need to override the standard mapping behavior for this specific property.
This parameter customizes how property values are converted to IRIs, enabling:
- IRI templates with placeholders (e.g., converting a username to a complete URI)
- Custom mappers for specialized IRI conversion
- Context-dependent IRI construction strategies
Available IriMapping constructor variants:
- Template constructor:
iri: IriMapping('{+baseUri}/profile/{propertyName}') .namedMapper()- references a mapper provided toinitRdfMapper.mapper()- uses a mapper type that will be instantiated.mapperInstance()- uses a specific mapper instance
Template placeholders are resolved in two ways:
- Property placeholders (e.g.,
{userId}) use the property's value directly - Context variables (e.g.,
{+baseUri}) are provided through:- Global provider functions in
initRdfMapper(e.g.,baseUriProvider: () => 'https://example.com') - Properties in the same class annotated with
@RdfProvides('baseUri') - The parent resource's IRI, when the parent's
IriStrategyspecifiesprovidedAsparameter - The
+prefix (e.g.,{+baseUri}) indicates variables that may contain URI-reserved characters like slashes, which should not be percent-encoded when substituted
- Global provider functions in
Example:
// Context variable provided by another property
@RdfProvides('baseUri')
final String serviceUrl = 'https://example.com';
// Using an IRI template for a property
@RdfProperty(
Dcterms.creator,
iri: IriMapping('{+baseUri}/profile/{userId}')
)
final String userId; // Converts to "https://example.com/profile/jsmith" if userId="jsmith"
Implementation
final IriMapping? iri;