001/*
002 * Licensed to DuraSpace under one or more contributor license agreements.
003 * See the NOTICE file distributed with this work for additional information
004 * regarding copyright ownership.
005 *
006 * DuraSpace licenses this file to you under the Apache License,
007 * Version 2.0 (the "License"); you may not use this file except in
008 * compliance with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.fcrepo.kernel.modeshape.rdf;
019
020import static org.apache.jena.rdf.model.ModelFactory.createDefaultModel;
021import static org.fcrepo.kernel.api.RdfLexicon.isManagedNamespace;
022import static org.fcrepo.kernel.api.RdfLexicon.isManagedPredicate;
023
024import java.util.function.Predicate;
025
026import org.apache.jena.graph.Triple;
027import org.apache.jena.rdf.model.Model;
028import org.apache.jena.rdf.model.Resource;
029
030/**
031 * {@link Predicate}s for determining when RDF is managed by the repository.
032 *
033 * @author ajs6f
034 * @since Oct 23, 2013
035 */
036public final class ManagedRdf {
037
038    private static final Model model = createDefaultModel();
039
040    /**
041     * No public constructor on utility class
042     */
043    private ManagedRdf() {
044    }
045
046    public static final Predicate<Triple> isManagedTriple =
047        p -> isManagedPredicate.test(model.asStatement(p).getPredicate());
048
049    public static final Predicate<Resource> isManagedMixin =
050        p -> isManagedNamespace.test(p.getNameSpace());
051}