template property

String? template
final

An optional template string for constructing the IRI.

Template variables are enclosed in curly braces and can be of two types:

  1. Class property variables: Correspond to properties in the class marked with @RdfIriPart

    • Example: In @RdfIri('urn:isbn:{value}'), the {value} variable will be replaced with the value of the property marked with @RdfIriPart() (or @RdfIriPart('value'))
    • When multiple properties use @RdfIriPart.position(), the generator creates a record-based mapper to handle complex multi-part IRIs
  2. Context variables: Variables like {+baseUri} or {+storageRoot} that are provided through one of three methods:

    • Via global provider functions in initRdfMapper (e.g., baseUriProvider: () => 'https://example.com'). The generator will automatically add a required parameter to initRdfMapper.
    • Via other properties in the same class annotated with @RdfProvides('baseUri'). This is preferred for context variables that are already available in the class.
    • Via the parent resource's IRI, when the parent's IriStrategy specifies providedAs parameter. This is useful for hierarchical structures where children need the parent's IRI.
    • The + prefix (e.g., {+baseUri}) indicates variables that may contain URI-reserved characters like slashes, which should not be percent-encoded when substituted

If no template is provided (template == null), the property marked with @RdfIriPart will be used as the complete IRI value.

Implementation

final String? template;