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 SiftsEntity implements Serializable{
032
033        /**
034         *
035         */
036        private static final long serialVersionUID = 750353252427491487L;
037        String type;
038        String entityId;
039
040        List<SiftsSegment> segments;
041
042        public SiftsEntity(){
043                this(null,null);
044        }
045
046        public SiftsEntity(String type, String entityId) {
047                this.type = type;
048                this.entityId = entityId;
049                segments = new ArrayList<SiftsSegment>();
050        }
051
052        public void addSegment(SiftsSegment s) {
053                segments.add(s);
054
055        }
056
057        public List<SiftsSegment> getSegments(){
058                return segments;
059        }
060
061        public void setSegments(List<SiftsSegment> segments){
062                this.segments = segments;
063        }
064
065        public String getType() {
066                return type;
067        }
068
069        public void setType(String type) {
070                this.type = type;
071        }
072
073        public String getEntityId() {
074                return entityId;
075        }
076
077        public void setEntityId(String entityId) {
078                this.entityId = entityId;
079        }
080
081        @Override
082        public String toString() {
083                return "SiftsEntity [type=" + type + ", entityId=" + entityId
084                                + ", segments=" + segments + "]";
085        }
086
087        @Override
088        public int hashCode() {
089                final int prime = 31;
090                int result = 1;
091                result = prime * result
092                                + ((entityId == null) ? 0 : entityId.hashCode());
093                result = prime * result
094                                + ((segments == null) ? 0 : segments.hashCode());
095                result = prime * result + ((type == null) ? 0 : type.hashCode());
096                return result;
097        }
098
099        @Override
100        public boolean equals(Object obj) {
101                if (this == obj)
102                        return true;
103                if (obj == null)
104                        return false;
105                if (getClass() != obj.getClass())
106                        return false;
107                SiftsEntity other = (SiftsEntity) obj;
108                if (entityId == null) {
109                        if (other.entityId != null)
110                                return false;
111                } else if (!entityId.equals(other.entityId))
112                        return false;
113                if (segments == null) {
114                        if (other.segments != null)
115                                return false;
116                } else if (!segments.equals(other.segments))
117                        return false;
118                if (type == null) {
119                        if (other.type != null)
120                                return false;
121                } else if (!type.equals(other.type))
122                        return false;
123                return true;
124        }
125
126
127
128}