Class Arr


  • public final class Arr
    extends Object
    • Field Detail

      • NOT_FOUND

        public static final int NOT_FOUND
        Constant to indicate not found element in array
        See Also:
        Constant Field Values
    • Method Detail

      • foreach

        public static <T> void foreach​(T @NotNull [] array,
                                       IAnyUtilsCallbacks.IForeach<T> callback)
        Foreach method
        Type Parameters:
        T - Generic type
        Parameters:
        array - Target array
        callback - Target execution callback
      • of

        @SafeVarargs
        public static <T> T[] of​(T... elements)
        Generate array from varargs.
        Type Parameters:
        T - Generic type
        Parameters:
        elements - All elements to select
        Returns:
        Return an array with all elements
      • longOf

        public static long[] longOf​(long... elements)
      • intOf

        public static int[] intOf​(int... elements)
      • boolOf

        public static boolean[] boolOf​(boolean... elements)
      • floatOf

        public static float[] floatOf​(float... elements)
      • doubleOf

        public static double[] doubleOf​(double... elements)
      • charOf

        public static char @NotNull [] charOf​(char... elements)
      • indexOf

        @Contract(pure=true)
        public static int indexOf​(Object @NotNull [] array,
                                  @NotNull
                                  @NotNull Object search)
        Search an element in the array
        Parameters:
        array - Target array
        search - Element to search
        Returns:
        Return the first index of element or -1 if element to search not exists
      • indexOf

        public static int indexOf​(int @NotNull [] array,
                                  int search)
      • lastIndexOf

        @Contract(pure=true)
        public static int lastIndexOf​(Object @NotNull [] array,
                                      @NotNull
                                      @NotNull Object search)
        Search an element in the array. This method make the same process that indexOf(Object[], Object) but inverted.
        Parameters:
        array - Target array
        search - Element to search
        Returns:
        Return the first last index of element or -1 if element to search not exists
      • lastIndexOf

        public static int lastIndexOf​(int @NotNull [] array,
                                      int search)
      • emptyOf

        public static <T> T[] emptyOf​(Class<T> ref)
        Generate any type of empty arrays
        Type Parameters:
        T - Generic type
        Parameters:
        ref - Class reference
        Returns:
        Returns an empty array
      • longEmpty

        public static long @NotNull [] longEmpty()
      • intEmpty

        public static int @NotNull [] intEmpty()
      • shortEmpty

        public static short @NotNull [] shortEmpty()
      • charEmpty

        public static char @NotNull [] charEmpty()
      • byteEmpty

        public static byte @NotNull [] byteEmpty()
      • booleanEmpty

        public static boolean @NotNull [] booleanEmpty()
      • floatEmpty

        public static float @NotNull [] floatEmpty()
      • doubleEmpty

        public static double @NotNull [] doubleEmpty()