Class ArrayHelper


  • public class ArrayHelper
    extends java.lang.Object
    A collection of static methods to help with using arrays of the Java language. This is an addition to Arrays.
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T findFirstMatch​(T[][] input, Predicate<T> predicate)
      Find the first element in the array that matches the predicate.
      static <T> T findFirstMatch​(T[] input, Predicate<T> predicate)
      Find the first element in the array that matches the predicate.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ArrayHelper

        public ArrayHelper()
    • Method Detail

      • findFirstMatch

        public static <T> T findFirstMatch​(T[] input,
                                           Predicate<T> predicate)
        Find the first element in the array that matches the predicate.
        Type Parameters:
        T - The type of element to use.
        Parameters:
        input - The array of candidates to match. Not null.
        predicate - The match condition. Not null.
        Returns:
        The first match or null if there is none.
      • findFirstMatch

        public static <T> T findFirstMatch​(T[][] input,
                                           Predicate<T> predicate)
        Find the first element in the array that matches the predicate. This is a two-dimensional version of #findFirstMatch(T[], Predicate), iteration is right-to-left as usual in Java.
        Type Parameters:
        T - The type of element to use.
        Parameters:
        input - The array of candidates to match. Not null.
        predicate - The match condition. Not null.
        Returns:
        The first match or null if there is none.