RdfDataset.fromGraphs constructor

RdfDataset.fromGraphs(
  1. List<RdfNamedGraph> graphs
)

Creates a dataset from a list of named graphs with an empty default graph

This factory constructor is convenient when you have a collection of named graphs and want to create a dataset with them. The default graph will be empty.

Parameters:

  • graphs List of RdfNamedGraph instances to include in the dataset

Throws:

Example:

final namedGraphs = [
  RdfNamedGraph(IriTerm('http://example.org/graph1'), graph1),
  RdfNamedGraph(IriTerm('http://example.org/graph2'), graph2),
];
final dataset = RdfDataset.fromGraphs(namedGraphs);

Implementation

RdfDataset.fromGraphs(List<RdfNamedGraph> graphs)
    : defaultGraph = RdfGraph(),
      _namedGraphs = Map.fromIterable(
        graphs,
        key: (g) => g.name,
        value: (g) => g.graph,
      );