Class SimpleComparableTriple

    • Method Detail

      • compareTo

        public int compareTo​(Object o)
        Triples are sorted in order of ontology, subject, object, and finally predicate.
        Specified by:
        compareTo in interface Comparable
      • equals

        public boolean equals​(Object o)
        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.

        Triples are equal only if they are from the same ontology and share the same subject, object and predicate.
        Specified by:
        equals in interface Triple
        Overrides:
        equals in class Object
      • hashCode

        public 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.

        Specified by:
        hashCode in interface Triple
        Overrides:
        hashCode in class Object
      • getName

        public String getName()
        Return the name of this term. Returns the output of toSring()
        Specified by:
        getName in interface Term
        Returns:
        the name of the term
      • getSubject

        public Term getSubject()
        Return the subject term of this triple
        Specified by:
        getSubject in interface Triple
        Returns:
        the subject term
      • getObject

        public Term getObject()
        Return the object term of this triple.
        Specified by:
        getObject in interface Triple
        Returns:
        the object term
      • getPredicate

        public Term getPredicate()
        Return a Term which defines the type of relationship between the subject and object terms.
        Specified by:
        getPredicate in interface Triple
        Returns:
        the predicate
      • getDescriptors

        public Set getDescriptors()
        Returns all descriptors. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.
        Specified by:
        getDescriptors in interface ComparableTriple
        Returns:
        a set of all ComparableTerm descriptors, possibly empty.
        See Also:
        ComparableTerm
      • setDescriptors

        public void setDescriptors​(Set descriptors)
                            throws ChangeVetoException
        Clears the current set of descriptors and replaces it with the content of the set passed. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.
        Specified by:
        setDescriptors in interface ComparableTriple
        Parameters:
        descriptors - the set of ComparableTerm descriptors to add.
        Throws:
        ChangeVetoException - in case of objections.
        See Also:
        ComparableTerm
      • addSynonym

        public void addSynonym​(Object synonym)
        Add a synonym for this term. NOT IMPLEMENTED
        Specified by:
        addSynonym in interface Term
        Parameters:
        synonym - the synonym
      • getSynonyms

        public Object[] getSynonyms()
        Return the synonyms for this term. ALWAYS RETURNS AN EMPTY LIST
        Specified by:
        getSynonyms in interface Term
        Returns:
        the synonyms
      • getDescription

        public String getDescription()
        Return a human-readable description of this term, or the empty string if none is available. ALWAYS RETURNS THE EMPTY STRING
        Specified by:
        getDescription in interface Term
        Returns:
        the description of the term
      • getId

        public Integer getId()
        Gets the Hibernate ID. Should be used with caution.
        Returns:
        the Hibernate ID, if using Hibernate.
      • setId

        public void setId​(Integer id)
        Sets the Hibernate ID. Should be used with caution.
        Parameters:
        id - the Hibernate ID, if using Hibernate.