RdfGraph class final
Represents an immutable RDF graph with triple pattern matching capabilities
An RDF graph is formally defined as a set of RDF triples. This class provides functionality for working with such graphs, including:
- Creating graphs from sets of triples
- Adding or removing triples (creating new graph instances)
- Merging graphs
- Querying triples based on patterns
The class is designed to be immutable for thread safety and to prevent accidental modification. All operations that would modify the graph return a new instance.
Example:
// Create a graph with some initial triples
final graph = RdfGraph(triples: [
Triple(john, name, johnSmith),
Triple(john, knows, jane)
]);
// Create a new graph with an additional triple
final updatedGraph = graph.withTriple(Triple(jane, name, janeSmith));
Constructors
-
RdfGraph.new({List<
Triple> triples = const []}) - Creates an immutable RDF graph from a list of triples
Properties
- hashCode → int
-
Provides a consistent hash code for this graph based on its triples.
no setteroverride
- isEmpty → bool
-
Whether this graph contains any triples
no setter
- isNotEmpty → bool
-
Whether this graph contains at least one triple
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
Number of triples in this graph
no setter
-
triples
→ List<
Triple> -
Get all triples in the graph
no setter
Methods
-
findTriples(
{RdfSubject? subject, RdfPredicate? predicate, RdfObject? object}) → List< Triple> - Find all triples matching the given pattern
-
getObjects(
RdfSubject subject, RdfPredicate predicate) → List< RdfObject> - Get all objects for a given subject and predicate
-
getSubjects(
RdfPredicate predicate, RdfObject object) → List< RdfSubject> - Get all subjects with a given predicate and object
-
merge(
RdfGraph other) → RdfGraph - Merges this graph with another, producing a new graph
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
withoutMatching(
{RdfSubject? subject, RdfPredicate? predicate, RdfObject? object}) → RdfGraph - Creates a new graph by filtering out triples that match a pattern
-
withTriple(
Triple triple) → RdfGraph - Creates a new graph with the specified triple added
-
withTriples(
List< Triple> triples) → RdfGraph - Creates a new graph with all the specified triples added
Operators
-
operator ==(
Object other) → bool -
We are implementing equals ourselves instead of using equatable,
because we want to compare the sets of triples, not the order
override
Static Methods
-
fromTriples(
List< Triple> triples) → RdfGraph - Creates an RDF graph from a list of triples (factory constructor)