X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureMapping.java;fp=src%2Fjalview%2Fstructure%2FStructureMapping.java;h=4174f5b8316eb82d900217207a4567d31ea1712d;hp=fcf322d44f6eaf8d69ea9d8a4937e1e17b77ecff;hb=9f1f7839cfd50555efd3af1ff4102348f950c563;hpb=e34a4c5332c2d4d92651e0adc99ab7c5d262d13b diff --git a/src/jalview/structure/StructureMapping.java b/src/jalview/structure/StructureMapping.java index fcf322d..4174f5b 100644 --- a/src/jalview/structure/StructureMapping.java +++ b/src/jalview/structure/StructureMapping.java @@ -30,6 +30,12 @@ import java.util.List; public class StructureMapping { + public static final int UNASSIGNED_VALUE = Integer.MIN_VALUE; + + private static final int PDB_RES_NUM_INDEX = 0; + + private static final int PDB_ATOM_NUM_INDEX = 1; + String mappingDetails; SequenceI sequence; @@ -40,17 +46,12 @@ public class StructureMapping String pdbchain; - public static final int UNASSIGNED_VALUE = Integer.MIN_VALUE; - - private static final int PDB_RES_NUM_INDEX = 0; - - private static final int PDB_ATOM_NUM_INDEX = 1; - // Mapping key is residue index while value is an array containing PDB resNum, // and atomNo HashMap mapping; jalview.datamodel.Mapping seqToPdbMapping = null; + /** * Constructor * @@ -145,7 +146,7 @@ public class StructureMapping */ public List getPDBResNumRanges(int fromSeqPos, int toSeqPos) { - List result = new ArrayList(); + List result = new ArrayList<>(); int startRes = -1; int endRes = -1; @@ -263,4 +264,105 @@ public class StructureMapping { return seqToPdbMapping; } + + /** + * A hash function that satisfies the contract that if two mappings are + * equal(), they have the same hashCode + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + + ((mappingDetails == null) ? 0 : mappingDetails.hashCode()); + result = prime * result + + ((pdbchain == null) ? 0 : pdbchain.hashCode()); + result = prime * result + ((pdbfile == null) ? 0 : pdbfile.hashCode()); + result = prime * result + ((pdbid == null) ? 0 : pdbid.hashCode()); + result = prime * result + + ((seqToPdbMapping == null) ? 0 : seqToPdbMapping.hashCode()); + result = prime * result + + ((sequence == null) ? 0 : sequence.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + StructureMapping other = (StructureMapping) obj; + if (mappingDetails == null) + { + if (other.mappingDetails != null) + { + return false; + } + } + else if (!mappingDetails.equals(other.mappingDetails)) + { + return false; + } + if (pdbchain == null) + { + if (other.pdbchain != null) + { + return false; + } + } + else if (!pdbchain.equals(other.pdbchain)) + { + return false; + } + if (pdbfile == null) + { + if (other.pdbfile != null) + { + return false; + } + } + else if (!pdbfile.equals(other.pdbfile)) + { + return false; + } + if (pdbid == null) + { + if (other.pdbid != null) + { + return false; + } + } + else if (!pdbid.equals(other.pdbid)) + { + return false; + } + if (seqToPdbMapping == null) + { + if (other.seqToPdbMapping != null) + { + return false; + } + } + else if (!seqToPdbMapping.equals(other.seqToPdbMapping)) + { + return false; + } + if (sequence != other.sequence) + { + return false; + } + + return true; + } }