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 */
021package org.biojava.nbio.structure.secstruc;
022
023import java.io.Serializable;
024
025/**
026 * Container that represents a beta Bridge between two residues. It contains the
027 * two partner indices and the type of the bridge. For consistency, partner1 is
028 * always the small index.
029 *
030 * @author Aleix Lafita
031 *
032 */
033public class BetaBridge implements Serializable {
034
035        private static final long serialVersionUID = -5097435425455958487L;
036
037        BridgeType type;
038        int partner1;
039        int partner2;
040
041        public BetaBridge(int i, int j, BridgeType t) {
042                partner1 = Math.min(i, j);
043                partner2 = Math.max(i, j);
044                type = t;
045        }
046
047        @Override
048                public int hashCode()
049                {
050                        final int prime = 31;
051                        int result = 1;
052                        result = prime * result + getType().hashCode();
053                        result = prime * result + partner1;
054                        result = prime * result + partner2;
055                        return result;
056                }
057
058        @Override
059        public boolean equals(Object o) {
060
061                if (!(o instanceof BetaBridge))
062                        return false;
063
064                BetaBridge b = (BetaBridge) o;
065                if (type != b.type)
066                        return false;
067                if (partner1 != b.partner1)
068                        return false;
069                if (partner2 != b.partner2)
070                        return false;
071                return true;
072        }
073
074        public BridgeType getType() {
075                return type;
076        }
077
078        public int getPartner1() {
079                return partner1;
080        }
081
082        public int getPartner2() {
083                return partner2;
084        }
085
086}