001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006package org.fcrepo.kernel.api; 007 008import java.util.stream.Collector; 009 010import org.apache.jena.rdf.model.ModelFactory; 011import org.apache.jena.graph.Triple; 012import org.apache.jena.rdf.model.Model; 013 014/** 015 * A class of Collectors for use with RdfStreams 016 * @author acoburn 017 * @since Dec 4, 2015 018 */ 019public class RdfCollectors { 020 021 /** 022 * @return a Collector for use with aggregating an RdfStream into a Model. 023 */ 024 public static Collector<Triple, ?, Model> toModel() { 025 return Collector.of(ModelFactory::createDefaultModel, 026 (m, t) -> m.add(m.asStatement(t)), 027 (left, right) -> { 028 left.add(right); 029 return left; 030 }, 031 Collector.Characteristics.UNORDERED); 032 } 033 034 private RdfCollectors() { 035 // prevent instantiation 036 } 037} 038