LocalResource class

Annotation for local RDF resources (blank nodes).

Marks a Dart class as a local resource (blank node) that exists only within the context of a parent resource. Unlike global resources (RootResource, SubResource), local resources do not have globally unique IRIs.

CRDT Merge Identification

For CRDT merging, blank nodes can be identified in two ways:

  • Single-path blank nodes: Reachable via exactly one property path from the parent resource (e.g., Category → displaySettings). No @MergeIdentifying() annotation needed.

  • Property-identified blank nodes: Multiple instances can exist and are matched during CRDT merge operations by a unique property marked with @MergeIdentifying() (e.g., Weblink instances matched by URL).

RDF Type (classIri)

Optionally specify an RDF type for the blank node via the classIri parameter. This is independent of merge identification and purely affects RDF serialization.

Usage Examples

Single-path blank node without RDF type:

@LocalResource()
class CategoryDisplaySettings {
  @RdfProperty(PersonalNotesVocab.categoryColor)
  @CrdtLwwRegister()
  final String? color;

  @RdfProperty(PersonalNotesVocab.categoryIcon)
  @CrdtLwwRegister()
  final String? icon;
}

Property-identified blank node with RDF type:

@LocalResource(PersonalNotesVocab.Weblink)
class Weblink {
  @RdfProperty(Schema.url)
  @MergeIdentifying()  // Identifies this blank node for CRDT merging
  @CrdtImmutable()
  final String url;

  @RdfProperty(Schema.name)
  @CrdtLwwRegister()
  final String? title;
}

CRDT Merge Strategies

Local resources inherit CRDT merge strategies from their parent RootResource's merge contract. Use standard CRDT property annotations:

  • @CrdtLwwRegister() - Last-Write-Wins (single value)
  • @CrdtOrSet() - Observed-Remove Set (multi-value, re-addable)
  • @CrdtImmutable() - Write-once, never changes

See Also

  • RootResource - Top-level resources with global IRIs
  • SubResource - Nested global resources with fragment IRIs
  • @MergeIdentifying() - Mark identifying properties for blank nodes
Inheritance
Implemented types

Constructors

LocalResource(AppVocab appVocab, {String? comment, String? label, List<(IriTerm, RdfObject)> metadata = const [], IriTerm? subClassOf})
const
LocalResource.externalVocab([IriTerm? classIri])
const

Properties

classIri → IriTerm?
The RDF class IRI for this blank node.
finalinherited
comment String?
Optional description for this class in define mode.
finalinherited
direction MapperDirection?
Specifies whether this mapper should handle serialization, deserialization, or both.
finalinherited
fragment String?
The fragment identifier for vocabulary generation mode.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
label String?
Optional human-readable label for this class in define mode.
finalinherited
mapper MapperRef<LocalResourceMapper>?
Provides a MapperRef if a custom mapper is specified.
no setterinherited
metadata List<(IriTerm, RdfObject)>?
Optional additional metadata triples for this class in define mode.
finalinherited
registerGlobally bool
Controls whether the generated mapper should be registered globally in the initRdfMapper function.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subClassOf → IriTerm?
The superclass for this resource in define mode.
finalinherited
vocab AppVocab?
The vocabulary configuration for define mode.
finalinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited