IriStrategy constructor
Creates a strategy for generating IRIs from resource properties.
Use this constructor with @RdfGlobalResource to have the generator create
an IRI mapper automatically. The generator will:
- Create a record type from all properties marked with
@RdfIriPart - Generate an
IriTermMapper<RecordType>implementation - Extract values from the resource into this record during serialization
- Set properties in the resource from the record during deserialization
(unless they are also annotated with
@RdfProperty, in which case the value from @RdfProperty takes precedence)
Template System
The template supports flexible IRI construction with:
- Property placeholders:
{propertyName}- values from@RdfIriPartproperties - Context variables:
{+contextVar}or{contextVar}- external values from providers - Reserved expansion: Use
{+variable}to preserve URI structure (like/)
Context variables enable deployment-specific configuration without hardcoding URIs. They are resolved from:
- Global providers in
initRdfMapper()whenregisterGlobally = true(default) - Parent class properties with
@RdfProvides()annotations - Constructor parameters when
registerGlobally = false
Examples:
// Property-based IRI
@RdfGlobalResource(Person.classIri, IriStrategy('http://example.org/people/{id}'))
class Person {
@RdfIriPart('id')
final String id;
}
// Context-aware IRI (auto-adds baseUriProvider to initRdfMapper)
@RdfGlobalResource(Book.classIri, IriStrategy('{+baseUri}/books/{isbn}'))
class Book {
@RdfIriPart('isbn')
final String isbn;
}
When the template contains unbound variables (not matching any property with @RdfIriPart),
the generator will automatically create provider parameters. With registerGlobally = true
(the default), these providers become required parameters in the initRdfMapper function.
The optional providedAs parameter allows this resource's IRI to be provided to dependent
mappers under the specified name. When set, child/dependent mappers can reference this IRI
in their templates using {providedName}.
Implementation
const IriStrategy([this.template, this.providedAs])
: fragmentTemplate = null,
super();