Interface Quad
-
- All Superinterfaces:
QuadLike<BlankNodeOrIRI>
,TripleLike
- All Known Subinterfaces:
JsonLdQuad
,RDF4JQuad
- All Known Implementing Classes:
JsonLdQuadImpl
,QuadImpl
,QuadImpl
public interface Quad extends QuadLike<BlankNodeOrIRI>
A Quad is a statement in a RDF-1.1 Dataset, as defined by RDF-1.1 Concepts and Abstract Syntax, a W3C Working Group Note published on 25 February 2014.A
Quad
object in Commons RDF is considered immutable, that is, over its life time it will have consistent behaviour for itsequals(Object)
, and the instances returned fromgetGraphName()
,getSubject()
,getPredicate()
,getObject()
andasTriple()
will have consistentObject.equals(Object)
behaviour.Note that
Quad
methods are not required to return object identical (==
) instances as long as they are equivalent according toObject.equals(Object)
. Specialisations ofQuad
may provide additional methods that are documented to be mutable.Quad
methods are thread-safe, however specialisations may provide additional methods that are documented to not be thread-safe.Quad
s can be safely used in hashing collections likeHashSet
andHashMap
.Any
Quad
can be used interchangeably across Commons RDF implementations.- Since:
- 0.3.0-incubating
- See Also:
Dataset
,RDF.createQuad(BlankNodeOrIRI,BlankNodeOrIRI,IRI,RDFTerm)
, RDF 1.1: On Semantics of RDF Datasets,
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Triple
asTriple()
Adapt this Quad to a Triple.boolean
equals(java.lang.Object other)
Check it this Quad is equal to another Quad.java.util.Optional<BlankNodeOrIRI>
getGraphName()
The graph name (graph label) of this quad, if present.RDFTerm
getObject()
IRI
getPredicate()
The predicateIRI
of this quad.BlankNodeOrIRI
getSubject()
The subject of this quad, which may be either aBlankNode
or anIRI
, which are represented in Commons RDF by the interfaceBlankNodeOrIRI
.int
hashCode()
Calculate a hash code for this Quad.
-
-
-
Method Detail
-
getGraphName
java.util.Optional<BlankNodeOrIRI> getGraphName()
The graph name (graph label) of this quad, if present. IfOptional.isPresent()
, then theOptional.get()
is either aBlankNode
or anIRI
, indicating the graph name of this Quad. If the graph name is not present, e.g. the value isOptional.empty()
, it indicates that this Quad is in the default graph.- Specified by:
getGraphName
in interfaceQuadLike<BlankNodeOrIRI>
- Returns:
- If
Optional.isPresent()
, the graph nameBlankNodeOrIRI
of this quad, otherwiseOptional.empty()
, indicating the default graph. - See Also:
- RDF- 1.1 Dataset
-
getSubject
BlankNodeOrIRI getSubject()
The subject of this quad, which may be either aBlankNode
or anIRI
, which are represented in Commons RDF by the interfaceBlankNodeOrIRI
.- Specified by:
getSubject
in interfaceTripleLike
- Returns:
- The subject
BlankNodeOrIRI
of this quad. - See Also:
- RDF-1.1 Triple subject
-
getPredicate
IRI getPredicate()
The predicateIRI
of this quad.- Specified by:
getPredicate
in interfaceTripleLike
- Returns:
- The predicate
IRI
of this quad. - See Also:
- RDF-1.1 Triple predicate
-
getObject
RDFTerm getObject()
The object of this quad, which may be either aBlankNode
, anIRI
, or aLiteral
, which are represented in Commons RDF by the interfaceRDFTerm
.- Specified by:
getObject
in interfaceTripleLike
- Returns:
- The object
RDFTerm
of this quad. - See Also:
- RDF-1.1 Triple object
-
asTriple
default Triple asTriple()
Adapt this Quad to a Triple.The returned
Triple
will have equivalent values returned from the methodsTripleLike.getSubject()
,TripleLike.getPredicate()
andTripleLike.getObject()
.The returned
Triple
MUST NOT beequals(Object)
to thisQuad
, even if this quad has a default graphgetGraphName()
value ofOptional.empty()
, but MUST follow theTriple.equals(Object)
semantics. This means that the following MUST be true:Quad q1, q2; if (q1.equals(q2)) { assert (q1.asTriple().equals(q2.asTriple())); } else if (q1.asTriple().equals(q2.asTriple())) { assert (q1.getSubject().equals(q2.getSubject())); assert (q1.getPredicate().equals(q2.getPredicate())); assert (q1.getObject().equals(q2.getObject())); assert (!q1.getGraphName().equals(q2.getGraphName())); }
Thedefault
implementation of this method return a proxyTriple
instance that keeps a reference to thisQuad
to call the underlyingTripleLike
methods, but supplies aTriple
compatible implementation ofTriple.equals(Object)
andTriple.hashCode()
. Implementations may override this method, e.g. for a more efficient solution.- Returns:
- A
Triple
that contains the sameTripleLike
properties as this Quad.
-
equals
boolean equals(java.lang.Object other)
Check it this Quad is equal to another Quad.Two Quads are equal if and only if their
getGraphName()
,getSubject()
,getPredicate()
andgetObject()
are equal.Implementations MUST also override
hashCode()
so that two equal Quads produce the same hash code.Note that a
Quad
MUST NOT be equal to aTriple
, even if this Quad'sgetGraphName()
isOptional.empty()
. To test triple-like equivalence, callers can use:Quad q1; Triple t2; q1.asTriple().equals(t2));
- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- Another object- Returns:
- true if other is a Quad and is equal to this
- See Also:
Object.equals(Object)
-
hashCode
int hashCode()
Calculate a hash code for this Quad.The returned hash code MUST be equal to the result of
Objects.hash(Object...)
with the argumentsgetSubject()
,getPredicate()
,getObject()
,getGraphName()
.This method MUST be implemented in conjunction with
equals(Object)
so that two equalQuad
s produce the same hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code value for this Quad.
- See Also:
Object.hashCode()
,Objects.hash(Object...)
-
-