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 Feb 22, 2012
021 * Created by Andreas Prlic
022 *
023 * @since 3.0.2
024 */
025package org.biojava.nbio.structure.io.sifts;
026
027import java.io.Serializable;
028import java.util.ArrayList;
029import java.util.List;
030
031public class SiftsSegment implements Serializable{
032
033
034        /**
035         *
036         */
037        private static final long serialVersionUID = -8005129863256307153L;
038        String segId;
039        String start;
040        String end;
041
042        List<SiftsResidue> residues;
043
044        public SiftsSegment(){
045                this(null,null,null);
046        }
047
048        public SiftsSegment(String segId, String start, String end) {
049                this.segId = segId;
050                this.start = start;
051                this.end = end;
052                residues = new ArrayList<SiftsResidue>();
053        }
054
055        public String getSegId() {
056                return segId;
057        }
058
059        public void setSegId(String segId) {
060                this.segId = segId;
061        }
062
063        public String getStart() {
064                return start;
065        }
066
067        public void setStart(String start) {
068                this.start = start;
069        }
070
071        public String getEnd() {
072                return end;
073        }
074
075        public void setEnd(String end) {
076                this.end = end;
077        }
078
079        public void addResidue(SiftsResidue pos) {
080                residues.add(pos);
081
082        }
083
084        public List<SiftsResidue> getResidues(){
085                return residues;
086        }
087
088        public void setResidues(List<SiftsResidue> residues){
089                this.residues = residues;
090        }
091
092        @Override
093        public String toString() {
094                return "SiftsSegment [segId=" + segId + ", start=" + start + ", end="
095                                + end + ", residues=" + residues + "]";
096        }
097
098        @Override
099        public int hashCode() {
100                final int prime = 31;
101                int result = 1;
102                result = prime * result + ((end == null) ? 0 : end.hashCode());
103                result = prime * result
104                                + ((residues == null) ? 0 : residues.hashCode());
105                result = prime * result + ((segId == null) ? 0 : segId.hashCode());
106                result = prime * result + ((start == null) ? 0 : start.hashCode());
107                return result;
108        }
109
110        @Override
111        public boolean equals(Object obj) {
112                if (this == obj)
113                        return true;
114                if (obj == null)
115                        return false;
116                if (getClass() != obj.getClass())
117                        return false;
118                SiftsSegment other = (SiftsSegment) obj;
119                if (end == null) {
120                        if (other.end != null)
121                                return false;
122                } else if (!end.equals(other.end))
123                        return false;
124                if (residues == null) {
125                        if (other.residues != null)
126                                return false;
127                } else if (!residues.equals(other.residues))
128                        return false;
129                if (segId == null) {
130                        if (other.segId != null)
131                                return false;
132                } else if (!segId.equals(other.segId))
133                        return false;
134                if (start == null) {
135                        if (other.start != null)
136                                return false;
137                } else if (!start.equals(other.start))
138                        return false;
139                return true;
140        }
141
142
143}