RdfGlobalResource.serializeOnly constructor
const
RdfGlobalResource.serializeOnly(
- IriTerm? classIri,
- IriStrategy iriStrategy, {
- bool registerGlobally = true,
Creates an annotation for serialization-only mapping.
Use this constructor when you only need to write RDF data from objects, but never need to reconstruct objects from RDF. An IRI strategy is required to generate the subject IRIs during serialization.
This is useful when:
- You're generating RDF data for export
- You don't need to read back the data you produce
- You want to make it explicit that deserialization is not supported
A serializer-only mapper is automatically generated based on the property
annotations in your class and registered within initRdfMapper when
registerGlobally is true.
Example:
@RdfGlobalResource.serializeOnly(
SchemaBook.classIri,
IriStrategy('http://example.org/book/{id}')
)
class Book {
@RdfIriPart('id')
final String id;
@RdfProperty(SchemaBook.name)
final String title;
// ...
}
Implementation
const RdfGlobalResource.serializeOnly(this.classIri, IriStrategy iriStrategy,
{super.registerGlobally = true})
: iri = iriStrategy,
vocab = null,
subClassOf = null,
metadata = null,
label = null,
comment = null,
fragment = null,
super(direction: MapperDirection.serializeOnly);