Package org.biojava.nbio.ontology
Interface Triple
- All Superinterfaces:
Annotatable
,Term
- All Known Implementing Classes:
Triple.Impl
A triple in an ontology. This is two terms and a relationship between
them, similar to RDF and other similar logic systems.
For documentation purposes, a Triple may provide a name. However, a Triple may also be named as "(subject, object, predicate)" if no specific name is provided.
- Since:
- 1.4
- Author:
- Thomas Down, Matthew Pocock
- See Also:
-
org.biojavax.ontology.ComparableTriple
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
Basic in-memory implementation of a Triple in an ontology This can be used to implement Ontology.createTriple -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check to see if an object is an equivalent Triple.Return the object term of this triple.Return a Term which defines the type of relationship between the subject and object terms.Return the subject term of this tripleint
hashCode()
The hashcode for a Triple.Methods inherited from interface org.biojava.nbio.ontology.utils.Annotatable
getAnnotation
Methods inherited from interface org.biojava.nbio.ontology.Term
addSynonym, getDescription, getName, getOntology, getSynonyms, removeSynonym, setDescription
-
Method Details
-
getSubject
Term getSubject()Return the subject term of this triple- Returns:
- the subject term
-
getObject
Term getObject()Return the object term of this triple.- Returns:
- the object term
-
getPredicate
Term getPredicate()Return a Term which defines the type of relationship between the subject and object terms.- Returns:
- the predicate
-
hashCode
int hashCode()The hashcode for a Triple.This must be implemented as:
return getSubject().hashCode() + 31 * getObject().hashCode() + 31 * 31 * getPredicate().hashCode();
If you do not implement hashcode in this way then you have no guarantee that your Triple objects will be found in an ontology and that they will not be duplicated. -
equals
Check to see if an object is an equivalent Triple.Two triples are equivalent if they have the same subject, object and predicate fields.
if (! (o instanceof Triple)) { return false; } Triple to = (Triple) o; return to.getSubject() == getSubject() && to.getObject() == getObject() && to.getPredicate() == getPredicate();
If you do not implement equals in this way then you have no guarantee that your Triple objects will be found in an ontology and that they will not be duplicated.
-