JAL-2418 source formatting
[jalview.git] / src / jalview / analysis / SequenceIdMatcher.java
index f744ed1..3d4cbe7 100755 (executable)
@@ -147,9 +147,8 @@ public class SequenceIdMatcher
       names.put(new SeqIdName(cand.getName()), cand);
       int q, w, candlen = cand.getName().length();
       // keep the one with an id 'closer' to the given seqnam string
-      if ((q = Math.abs(matchlen - namlen)) > (w = Math.abs(candlen
-              - namlen))
-              && candlen > matchlen)
+      if ((q = Math.abs(matchlen - namlen)) > (w = Math
+              .abs(candlen - namlen)) && candlen > matchlen)
       {
         best.clear();
         match = cand;
@@ -290,7 +289,7 @@ public class SequenceIdMatcher
     {
       if (s != null)
       {
-        id = new String(s.toLowerCase());
+        id = s.toLowerCase();
       }
       else
       {
@@ -301,8 +300,8 @@ public class SequenceIdMatcher
     @Override
     public int hashCode()
     {
-      return ((id.length() >= 4) ? id.substring(0, 4).hashCode() : id
-              .hashCode());
+      return ((id.length() >= 4) ? id.substring(0, 4).hashCode()
+              : id.hashCode());
     }
 
     @Override
@@ -314,13 +313,13 @@ public class SequenceIdMatcher
       }
       if (s instanceof SeqIdName)
       {
-        return this.equals(((SeqIdName) s).id);
+        return this.stringequals(((SeqIdName) s).id);
       }
       else
       {
         if (s instanceof String)
         {
-          return this.equals((String) s);
+          return this.stringequals(((String) s).toLowerCase());
         }
       }
 
@@ -344,18 +343,31 @@ public class SequenceIdMatcher
      * @param s
      * @return boolean
      */
-    public boolean equals(String s)
+    private boolean stringequals(String s)
     {
       if (id.length() > s.length())
       {
-        return id.startsWith(s) ? (WORD_SEP.indexOf(id.charAt(s.length())) > -1)
+        return id.startsWith(s)
+                ? (WORD_SEP.indexOf(id.charAt(s.length())) > -1)
                 : false;
       }
       else
       {
-        return s.startsWith(id) ? (s.equals(id) ? true : (WORD_SEP
-                .indexOf(s.charAt(id.length())) > -1)) : false;
+        return s.startsWith(id)
+                ? (s.equals(id) ? true
+                        : (WORD_SEP.indexOf(s.charAt(id.length())) > -1))
+                : false;
       }
     }
+
+    /**
+     * toString method returns the wrapped sequence id. For debugging purposes
+     * only, behaviour not guaranteed not to change.
+     */
+    @Override
+    public String toString()
+    {
+      return id;
+    }
   }
 }