Merge develop to Release_2_8_3_Branch
[jalview.git] / src / jalview / datamodel / DBRefEntry.java
index 887a751..0581845 100755 (executable)
@@ -1,20 +1,22 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
  * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
  * 
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.datamodel;
 
@@ -40,14 +42,14 @@ public class DBRefEntry
   /**
    * 
    * @param source
-   *                canonical source (uppercase only)
+   *          canonical source (uppercase only)
    * @param version
-   *                (source dependent version string)
+   *          (source dependent version string)
    * @param accessionId
-   *                (source dependent accession number string)
+   *          (source dependent accession number string)
    * @param map
-   *                (mapping from local sequence numbering to source accession
-   *                numbering)
+   *          (mapping from local sequence numbering to source accession
+   *          numbering)
    */
   public DBRefEntry(String source, String version, String accessionId,
           Mapping map)
@@ -67,12 +69,20 @@ public class DBRefEntry
             (entry.map == null ? null : new Mapping(entry.map)));
   }
 
-  public boolean equals(DBRefEntry entry)
+  @Override
+  public boolean equals(Object o)
   {
+    // TODO should also override hashCode to ensure equal objects have equal
+    // hashcodes
+    if (o == null || !(o instanceof DBRefEntry))
+    {
+      return false;
+    }
+    DBRefEntry entry = (DBRefEntry) o;
     if (entry == this)
+    {
       return true;
-    if (entry == null)
-      return false;
+    }
     if (equalRef(entry)
             && ((map == null && entry.map == null) || (map != null
                     && entry.map != null && map.equals(entry.map))))
@@ -95,7 +105,9 @@ public class DBRefEntry
       return false;
     }
     if (entry == this)
+    {
       return true;
+    }
     if ((source != null && entry.source != null && source
             .equalsIgnoreCase(entry.source))
             && (accessionId != null && entry.accessionId != null && accessionId
@@ -125,7 +137,7 @@ public class DBRefEntry
 
   /**
    * @param accessionId
-   *                the accessionId to set
+   *          the accessionId to set
    */
   public void setAccessionId(String accessionId)
   {
@@ -134,7 +146,7 @@ public class DBRefEntry
 
   /**
    * @param source
-   *                the source to set
+   *          the source to set
    */
   public void setSource(String source)
   {
@@ -143,7 +155,7 @@ public class DBRefEntry
 
   /**
    * @param version
-   *                the version to set
+   *          the version to set
    */
   public void setVersion(String version)
   {
@@ -160,7 +172,7 @@ public class DBRefEntry
 
   /**
    * @param map
-   *                the map to set
+   *          the map to set
    */
   public void setMap(Mapping map)
   {
@@ -181,4 +193,9 @@ public class DBRefEntry
     return ((source != null) ? source : "") + ":"
             + ((accessionId != null) ? accessionId : "");
   }
+
+  public String toString()
+  {
+    return getSrcAccString();
+  }
 }