RdfIriPart class
Marks a property as a part of the IRI for the enclosing class.
Used in classes annotated with @RdfIri or @RdfGlobalResource to designate
properties that contribute to IRI construction. This annotation creates a binding
between template variables and property values.
Supported Property Types
This annotation works with:
- Instance fields: Compatible with all type-annotated fields (mutable,
final, andlate) - Getters and setters: Both getter and setter must be provided.
- Only public properties: Private properties (with underscore prefix) are not supported.
For classes with @RdfIri (or indirectly with @IriMapping), all properties necessary for complete serialization/deserialization
must be annotated with @RdfIriPart. The instance must be fully reconstructable from just
these annotated properties.
Usage with IriStrategy
The annotation has different usage patterns depending on the IriStrategy constructor:
-
With the default constructor (
IriStrategy(template)), use the standard form@RdfIriPart([name])- the generator handles record creation automatically. -
With custom mappers (
IriStrategy.namedMapper(),.mapper(), or.mapperInstance()), use@RdfIriPart.position(index, [name])for multiple properties to ensure correct positioning in the record passed to your mapper.
Examples
Example with named template variable (generated mapper):
@RdfGlobalResource(SchemaBook.classIri, IriStrategy('http://example.org/book/{id}'))
class Book {
@RdfIriPart('id') // Property value replaces {id} in the template
final String id;
// ...
}
Example with unnamed (default) template variable:
@RdfIri('urn:isbn:{value}')
class ISBN {
@RdfIriPart() // Property name 'value' is used as the variable name
final String value;
// ...
}
Example with positional parts for custom mappers:
@RdfGlobalResource(
Product.classIri,
IriStrategy.namedMapper('productIdMapper')
)
class Product {
@RdfIriPart.position(1) // First position in the generated record type
final String category;
@RdfIriPart.position(2) // Second position in the generated record type
final String id;
// ...
}
- Implemented types
Constructors
- RdfIriPart([String? name])
-
Creates an IRI part annotation with a given
name.const - RdfIriPart.position(int position, [String? name])
-
Creates an IRI part annotation with a given
position.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String?
-
The name of the IRI part. This corresponds to a named template variable
in the
RdfIritemplate (e.g.,idfor{id}).final - pos → int?
-
The positional index of the IRI part, used when the IRI is constructed
from multiple unnamed parts, typically for record types in custom mappers.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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