template property

String? template
final

An optional template string for constructing IRIs from resource properties.

The template can contain static text combined with variables in curly braces. Two variable expansion syntaxes are supported:

  • Standard variables ({variable}): Values are percent-encoded according to URI standards
  • Reserved expansion ({+variable}): Values containing URI-reserved characters like slashes are not percent-encoded, preserving them as structural URI components

Variables are resolved in the following order:

  1. Class property variables: Bound to properties marked with @RdfIriPart

    • Example: IriStrategy('urn:isbn:{isbn}') where {isbn} is replaced with the value of a property marked with @RdfIriPart('isbn')
    • Multiple properties can be combined: {+baseUrl}/users/{userId}/profiles/{profileId}
  2. Context variables: Any variable not bound to a property (commonly using + prefix)

    • When used with registerGlobally = true (default):
      • The generator adds provider parameters to initRdfMapper
      • Example: {+baseUri} creates required baseUriProvider: () => 'https://example.org'
    • When used with registerGlobally = false:
      • The mapper looks for:
        • Properties in the parent class with @RdfProvides('variableName')
        • Or adds the provider as a required constructor parameter
    • 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 directly as the complete IRI value.

Implementation

final String? template;