View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.commons.rdf.api;
19  
20  import java.util.Optional;
21  
22  /**
23   * A generalised "quad-like" interface, extended by {@link Quad}.
24   * <p>
25   * A QuadLike statement has at least a {@link #getSubject()},
26   * {@link #getPredicate()}, {@link #getObject()} and {@link #getGraphName()},
27   * but unlike a {@link Quad} does not have a formalised
28   * {@link Quad#equals(Object)} or {@link Quad#hashCode()} semantics and is not
29   * required to be <em>immutable</em> or <em>thread-safe</em>. This interface can
30   * also be used for <em>generalised quads</em> (e.g. a {@link BlankNode} as
31   * predicate).
32   * <p>
33   * Implementations should specialise which specific {@link RDFTerm} types they
34   * return by overriding {@link #getSubject()}, {@link #getPredicate()},
35   * {@link #getObject()} and {@link #getGraphName()}.
36   *
37   * @since 0.3.0-incubating
38   * @see Quad
39   */
40  public interface QuadLike<G extends RDFTerm> extends TripleLike {
41  
42      /**
43       * The graph name (graph label) of this statement, if present.
44       * <p>
45       * If {@link Optional#isPresent()}, then the {@link Optional#get()} indicate
46       * the graph name of this statement. If the graph name is not present,e.g.
47       * the value is {@link Optional#empty()}, it indicates that this Quad is in
48       * the default graph.
49       *
50       * @return If {@link Optional#isPresent()}, the graph name of this quad,
51       *         otherwise {@link Optional#empty()}, indicating the default graph.
52       *         The graph name is typically an {@link IRI} or {@link BlankNode}.
53       */
54      Optional<G> getGraphName();
55  
56  }