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.api; 019 020import java.util.Optional; 021 022/** 023 * A generalised "quad-like" interface, extended by {@link Quad}. 024 * <p> 025 * A QuadLike statement has at least a {@link #getSubject()}, 026 * {@link #getPredicate()}, {@link #getObject()} and {@link #getGraphName()}, 027 * but unlike a {@link Quad} does not have a formalised 028 * {@link Quad#equals(Object)} or {@link Quad#hashCode()} semantics and is not 029 * required to be <em>immutable</em> or <em>thread-safe</em>. This interface can 030 * also be used for <em>generalised quads</em> (e.g. a {@link BlankNode} as 031 * predicate). 032 * <p> 033 * Implementations should specialise which specific {@link RDFTerm} types they 034 * return by overriding {@link #getSubject()}, {@link #getPredicate()}, 035 * {@link #getObject()} and {@link #getGraphName()}. 036 * 037 * @since 0.3.0-incubating 038 * @see Quad 039 */ 040public interface QuadLike<G extends RDFTerm> extends TripleLike { 041 042 /** 043 * The graph name (graph label) of this statement, if present. 044 * <p> 045 * If {@link Optional#isPresent()}, then the {@link Optional#get()} indicate 046 * the graph name of this statement. If the graph name is not present,e.g. 047 * the value is {@link Optional#empty()}, it indicates that this Quad is in 048 * the default graph. 049 * 050 * @return If {@link Optional#isPresent()}, the graph name of this quad, 051 * otherwise {@link Optional#empty()}, indicating the default graph. 052 * The graph name is typically an {@link IRI} or {@link BlankNode}. 053 */ 054 Optional<G> getGraphName(); 055 056}