Interface Triple
-
- All Superinterfaces:
TripleLike
- All Known Subinterfaces:
JsonLdTriple
,RDF4JTriple
- All Known Implementing Classes:
JsonLdTripleImpl
,TripleImpl
,TripleImpl
public interface Triple extends TripleLike
An RDF-1.1 Triple, as defined by RDF-1.1 Concepts and Abstract Syntax, a W3C Recommendation published on 25 February 2014.A
Triple
object in Commons RDF is considered immutable, that is, over its life time it will have consistent behaviour for itsequals(Object)
, and theRDFTerm
instances returned fromgetSubject()
,getPredicate()
andgetObject()
will have consistentRDFTerm.equals(Object)
behaviour.Note that
Triple
methods are not required to return object identical (==
) instances as long as they are equivalent according toRDFTerm.equals(Object)
. Specialisations ofTriple
may provide additional methods that are documented to be mutable.Triple
methods are thread-safe, however specialisations may provide additional methods that are documented to not be thread-safe.Triple
s can be safely used in hashing collections likeHashSet
andHashMap
.Any
Triple
can be used interchangeably across Commons RDF implementations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
Check it this Triple is equal to another Triple.RDFTerm
getObject()
IRI
getPredicate()
The predicateIRI
of this triple.BlankNodeOrIRI
getSubject()
The subject of this triple, which may be either aBlankNode
or anIRI
, which are represented in Commons RDF by the interfaceBlankNodeOrIRI
.int
hashCode()
Calculate a hash code for this Triple.
-
-
-
Method Detail
-
getSubject
BlankNodeOrIRI getSubject()
The subject of this triple, 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 triple. - See Also:
- RDF-1.1 Triple subject
-
getPredicate
IRI getPredicate()
The predicateIRI
of this triple.- Specified by:
getPredicate
in interfaceTripleLike
- Returns:
- The predicate
IRI
of this triple. - See Also:
- RDF-1.1 Triple predicate
-
getObject
RDFTerm getObject()
The object of this triple, 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 triple. - See Also:
- RDF-1.1 Triple object
-
equals
boolean equals(java.lang.Object other)
Check it this Triple is equal to another Triple.Two Triples are equal if and only if their
getSubject()
,getPredicate()
andgetObject()
are equal.Implementations MUST also override
hashCode()
so that two equal Triples produce the same hash code.- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- Another object- Returns:
- true if other is a Triple and is equal to this
- See Also:
Object.equals(Object)
-
hashCode
int hashCode()
Calculate a hash code for this Triple.The returned hash code MUST be equal to the result of
Objects.hash(Object...)
with the argumentsgetSubject()
,getPredicate()
,getObject()
.This method MUST be implemented in conjunction with
equals(Object)
so that two equalTriple
s produce the same hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code value for this Triple.
- See Also:
Object.hashCode()
,Objects.hash(Object...)
-
-