JAL-2795 changed getting index of identifier to Stream (moved to Java 8)
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Mon, 30 Oct 2017 17:15:07 +0000 (17:15 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Mon, 30 Oct 2017 17:20:58 +0000 (17:20 +0000)
Searching through with Stream prevents having to duplicate the array
with Arrays.toList

src/jalview/ext/forester/ForesterMatrix.java

index 4ce3d12..5450afe 100644 (file)
@@ -7,7 +7,7 @@ import java.io.IOException;
 import java.io.Writer;
 import java.text.DecimalFormat;
 import java.text.NumberFormat;
-import java.util.Arrays;
+import java.util.stream.IntStream;
 
 import org.forester.evoinference.matrix.distance.DistanceMatrix;
 import org.forester.util.ForesterUtil;
@@ -58,7 +58,9 @@ public class ForesterMatrix implements DistanceMatrix
   @Override
   public int getIndex(final String identifier)
   {
-    return Arrays.asList(identifiers).indexOf(identifier);
+    return IntStream.range(0, identifiers.length)
+            .filter(x -> identifier.equals(identifiers[x])).findFirst()
+            .orElse(-1);
   }
 
   /**