RdfGlobalResource constructor

const RdfGlobalResource(
  1. IriTerm? classIri,
  2. IriStrategy iriStrategy, {
  3. bool registerGlobally = true,
})

Creates an annotation for a class whose instances will be mapped to RDF subjects with specific IRIs.

This standard constructor creates a mapper that will create RDF triples from instances of the annotated class. The generated mapper is automatically registered within initRdfMapper when registerGlobally is true (the default).

Set registerGlobally to false if this mapper should not be registered automatically. This is required when the generated mapper needs providers injected in its constructor which should be provided by a parent class and not globally in initRdfMapper. This can happen in these cases:

  1. The mapper's own iriStrategy contains a template variable that isn't provided by this resource class via an @RdfIriPart annotation. Note: For the resource's own IRI, only @RdfIriPart is considered, not @RdfProvides.

  2. Any @RdfProperty annotation in this class has an IriMapping that contains a template variable not provided by this resource class via an @RdfProvides annotation or by a parent's IriStrategy.providedAs.

  3. The @RdfIri annotation of any @RdfProperty's value class contains registerGlobally: false (so it will be instantiated by this resource mapper instead of using the globally registered mapper) and contains a template variable not provided by either:

    • The value class's own @RdfIriPart annotations
    • This resource class via @RdfProvides annotations
    • A parent resource via IriStrategy.providedAs parameter

Also set to false if you want to manually manage the mapper registration.

classIri specifies the rdf:type for the resource, which defines what kind of entity this is in RDF terms. It is optional, but it's highly recommended to provide a class IRI to ensure proper typing in the RDF graph. iriStrategy defines the IRI construction strategy for instances of this class, which determines how unique identifiers are generated for each instance (typically based on annotated properties). registerGlobally controls whether the generated mapper should be registered globally in the initRdfMapper function. Set to false when the mapper should not be globally accessible, typically when all required context will be provided by parent objects via @RdfProvides annotations or via the parent's IriStrategy.providedAs parameter.

Example:

@RdfGlobalResource(SchemaBook.classIri, IriStrategy('http://example.org/book/{id}'))
class Book {
  @RdfIriPart('id')
  final String id;
  // ...
}

Implementation

const RdfGlobalResource(this.classIri, IriStrategy iriStrategy,
    {super.registerGlobally = true})
    : iri = iriStrategy,
      vocab = null,
      subClassOf = null,
      metadata = null,
      label = null,
      comment = null,
      fragment = null,
      super();