Package org.biojavax.bio
Class SimpleBioEntryRelationship
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojavax.bio.SimpleBioEntryRelationship
-
- All Implemented Interfaces:
Comparable,Changeable,BioEntryRelationship
public class SimpleBioEntryRelationship extends AbstractChangeable implements BioEntryRelationship
Represents a relationship between two bioentries that is described by a term and given a rank.- Since:
- 1.5
- Author:
- Richard Holland, Mark Schreiber, George Waldon
-
-
Field Summary
-
Fields inherited from interface org.biojavax.bio.BioEntryRelationship
RANK
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleBioEntryRelationship()SimpleBioEntryRelationship(BioEntry object, BioEntry subject, ComparableTerm term, Integer rank)Creates a new instance of SimpleBioEntryRelationship.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Object o)A relationship is compared first by rank, then object, subject, and term.booleanequals(Object obj)Relationships are equal if they share the same rank, object, subject and term.IntegergetId()Gets the Hibernate ID.BioEntrygetObject()Returns the object of this relationship (ie. the BioEntry which this relationship starts from).IntegergetRank()Returns the rank of this relationship.BioEntrygetSubject()Returns the subject of this relationship (ie. the BioEntry which this relationship targets).ComparableTermgetTerm()Returns the term describing the relationship.inthashCode()voidsetId(Integer id)Sets the Hibernate ID.voidsetRank(Integer rank)Sets the rank of this relationship.StringtoString()Form is "(#rank) term(object,subject)"-
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
-
-
-
Constructor Detail
-
SimpleBioEntryRelationship
public SimpleBioEntryRelationship(BioEntry object, BioEntry subject, ComparableTerm term, Integer rank)
Creates a new instance of SimpleBioEntryRelationship. None of the parameters may be null, and all are immutable except the rank.- Parameters:
rank- The rank of the relationship.subject- The subject bioentry.term- The relationship term.
-
SimpleBioEntryRelationship
protected SimpleBioEntryRelationship()
-
-
Method Detail
-
setRank
public void setRank(Integer rank) throws ChangeVetoException
Sets the rank of this relationship. The rank may be null in the database, hence the use of an Integer object here and not an int primitive.- Specified by:
setRankin interfaceBioEntryRelationship- Parameters:
rank- Value of property rank.- Throws:
ChangeVetoException- if the rank rankles.
-
getRank
public Integer getRank()
Returns the rank of this relationship. The rank may be null in the database, hence the use of an Integer object here and not an int primitive.- Specified by:
getRankin interfaceBioEntryRelationship- Returns:
- Value of property rank.
-
getObject
public BioEntry getObject()
Returns the object of this relationship (ie. the BioEntry which this relationship starts from). This is an immutable property set by the constructor of an instantiating class.- Specified by:
getObjectin interfaceBioEntryRelationship- Returns:
- Value of property object.
-
getSubject
public BioEntry getSubject()
Returns the subject of this relationship (ie. the BioEntry which this relationship targets). This is an immutable property set by the constructor of an instantiating class.- Specified by:
getSubjectin interfaceBioEntryRelationship- Returns:
- Value of property subject.
-
getTerm
public ComparableTerm getTerm()
Returns the term describing the relationship. This is an immutable property set by the constructor of an instantiating class.- Specified by:
getTermin interfaceBioEntryRelationship- Returns:
- Value of property term.
-
compareTo
public int compareTo(Object o)
A relationship is compared first by rank, then object, subject, and term. If ranks are null, they are treated as zero for comparison's sake.- Specified by:
compareToin interfaceComparable
-
equals
public boolean equals(Object obj)
Relationships are equal if they share the same rank, object, subject and term. If ranks are null, they are treated as zero for consistency with comparison.
-
getId
public Integer getId()
Gets the Hibernate ID. Should be used with caution.- Returns:
- the Hibernate ID, if using Hibernate.
-
-