001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * 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.apache.commons.rdf.rdf4j;
019
020import java.util.Optional;
021
022import org.apache.commons.rdf.api.GraphLike;
023import org.apache.commons.rdf.api.TripleLike;
024import org.eclipse.rdf4j.model.Model;
025import org.eclipse.rdf4j.repository.Repository;
026
027/**
028 * Marker interface for RDF4J implementations of GraphLike.
029 * <p>
030 * This is a common interface for {@link RDF4JGraph} and {@link RDF4JDataset}
031 * which provides access to the underlying RDF4J {@link Model} and/or
032 * {@link Repository}.
033 * <p>
034 * At least one of {@link #asModel()} or {@link #asRepository()} will always be
035 * {@link Optional#isPresent()}.
036 *
037 * @see RDF4JDataset
038 * @see RDF4JGraph
039 */
040public interface RDF4JGraphLike<T extends TripleLike> extends GraphLike<T>, AutoCloseable {
041
042    /**
043     * Return the corresponding RDF4J {@link Model}, if present.
044     * <p>
045     * The return value is {@link Optional#isPresent()} if this is backed by a
046     * Model.
047     * <p>
048     * Changes to the Model are reflected in both directions.
049     *
050     * @return The corresponding RDF4J Model.
051     */
052    Optional<Model> asModel();
053
054    /**
055     * Return the corresponding RDF4J {@link Repository}, if present.
056     * <p>
057     * The return value is {@link Optional#isPresent()} if this is backed by a
058     * Repository.
059     * <p>
060     * Changes to the Repository are reflected in both directions.
061     *
062     * @return The corresponding RDF4J Repository.
063     */
064    Optional<Repository> asRepository();
065
066}