RdfLocalResource constructor

const RdfLocalResource([
  1. IriTerm? classIri,
  2. bool registerGlobally = true,
  3. MapperDirection direction = MapperDirection.both
])

Creates an annotation for a class whose instances will be mapped to RDF blank nodes.

This standard constructor creates a mapper that will create RDF triples from instances of the annotated class, with each instance represented as a blank node. 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. Any @RdfProperty annotation in this class has an IriMapping that contains a template variable not provided by this resource class via an @RdfProvides annotation.

  2. 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

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

classIri specifies the rdf:type for the blank node, 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.

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.

Unlike RdfGlobalResource, no IRI construction strategy is needed since blank nodes are anonymous resources that do not have permanent identifiers.

Example:

@RdfLocalResource(SchemaChapter.classIri)
class Chapter {
  @RdfProperty(SchemaChapter.name)
  final String title;

  @RdfProperty(SchemaChapter.position)
  final int number;
  // ...
}

Implementation

const RdfLocalResource(
    [this.classIri,
    bool registerGlobally = true,
    MapperDirection direction = MapperDirection.both])
    : super(registerGlobally: registerGlobally, direction: direction);