Merge branch 'JAL-3878_ws-overhaul-3' into mmw/Release_2_12_ws_merge
[jalview.git] / src / jalview / util / ArrayUtils.java
index c05dac5..e141d07 100644 (file)
@@ -20,6 +20,8 @@
  */
 package jalview.util;
 
+import java.util.Objects;
+
 public class ArrayUtils
 {
   /**
@@ -44,4 +46,24 @@ public class ArrayUtils
       }
     }
   }
+
+  /**
+   * Return the index of the first occurrence of the item in the array or -1 if
+   * the array doesn't contain the item.
+   * 
+   * @param arr
+   *          array to be searched
+   * @param item
+   *          item to search for
+   * @return index of the first occurrence of the item or -1 if not found
+   */
+  public static int indexOf(Object[] arr, Object item)
+  {
+    for (int i = 0; i < arr.length; i++)
+    {
+      if (Objects.equals(arr[i], item))
+        return i;
+    }
+    return -1;
+  }
 }