RdfGlobalResource constructor
- IriTerm? classIri,
- IriStrategy iriStrategy, {
- 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:
-
The mapper's own
iriStrategycontains a template variable that isn't provided by this resource class via an@RdfIriPartannotation. Note: For the resource's own IRI, only@RdfIriPartis considered, not@RdfProvides. -
Any
@RdfPropertyannotation in this class has an IriMapping that contains a template variable not provided by this resource class via an@RdfProvidesannotation or by a parent'sIriStrategy.providedAs. -
The
@RdfIriannotation of any@RdfProperty's value class containsregisterGlobally: 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
@RdfIriPartannotations - This resource class via
@RdfProvidesannotations - A parent resource via
IriStrategy.providedAsparameter
- The value class's own
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();