001    /*
002     *                    BioJava development code
003     *
004     * This code may be freely distributed and modified under the
005     * terms of the GNU Lesser General Public Licence.  This should
006     * be distributed with the code.  If you do not have a copy,
007     * see:
008     *
009     *      http://www.gnu.org/copyleft/lesser.html
010     *
011     * Copyright for this code is held jointly by the individual
012     * authors.  These should be listed in @author doc comments.
013     *
014     * For more information on the BioJava project and its aims,
015     * or to join the biojava-l mailing list, visit the home page
016     * at:
017     *
018     *      http://www.biojava.org/
019     *
020     * Created on DATE
021     *
022     */
023    
024    package org.biojava3.core.sequence.compound;
025    
026    import org.biojava3.core.sequence.template.AbstractCompound;
027    import org.biojava3.core.sequence.template.Compound;
028    import org.biojava3.core.sequence.template.CompoundSet;
029    
030    /**
031     * Used to describe an Amino Acid.
032     * @author Richard Holland
033     * @author Scooter Willis
034     * @author Andy Yates
035     */
036    public class AminoAcidCompound extends AbstractCompound {
037    
038      private final AminoAcidCompoundSet compoundSet;
039    
040      public AminoAcidCompound(AminoAcidCompoundSet compoundSet, String shortName,
041          String longName, String description, Float molecularWeight) {
042        super(shortName);
043        setShortName(shortName);
044        setLongName(longName);
045        setDescription(description);
046        setMolecularWeight(molecularWeight);
047        this.compoundSet = compoundSet;
048      }
049    
050      // TODO need to allow for modified name; that's not equality though is it?
051      public boolean equals(Object obj) {
052        if (obj == null) {
053          return false;
054        }
055        if (!(obj instanceof AminoAcidCompound)) {
056          return false;
057        }
058        AminoAcidCompound them = (AminoAcidCompound) obj;
059        if (toString().equals(them.toString())) {
060          return true;
061        }
062        return getLongName().equals(them.getLongName());
063    
064      }
065    
066      public int hashCode() {
067        return toString().hashCode();
068      }
069    
070      public boolean equalsIgnoreCase(Compound compound) {
071        if (compound == null) {
072          return false;
073        }
074        if (!(compound instanceof AminoAcidCompound)) {
075          return false;
076        }
077        AminoAcidCompound them = (AminoAcidCompound) compound;
078        if (toString().equalsIgnoreCase(them.toString())) {
079          return true;
080        }
081        return getLongName().equalsIgnoreCase(them.getLongName());
082      }
083    
084      public CompoundSet<AminoAcidCompound> getCompoundSet() {
085        return compoundSet;
086      }
087    }