withoutMatching method
- RdfSubject? subject,
- RdfPredicate? predicate,
- RdfObject? object,
Creates a new graph by filtering out triples that match a pattern
This method removes triples that match the specified pattern components. If multiple pattern components are provided, they are treated as an OR condition (i.e., if any of them match, the triple is removed).
Parameters:
subject
Optional subject to match for removalpredicate
Optional predicate to match for removalobject
Optional object to match for removal
Returns: A new graph instance with matching triples removed
Example:
// Remove all triples about Jane
final withoutJane = graph.withoutMatching(subject: jane);
// Remove all name and email triples
final withoutContactInfo = graph.withoutMatching(
predicate: name,
object: email
);
Implementation
RdfGraph withoutMatching({
RdfSubject? subject,
RdfPredicate? predicate,
RdfObject? object,
}) {
final filteredTriples = _triples.where((triple) {
if (subject != null && triple.subject == subject) return false;
if (predicate != null && triple.predicate == predicate) return false;
if (object != null && triple.object == object) return false;
return true;
}).toList();
return RdfGraph(triples: filteredTriples);
}