package me.zero.client.api.util;

import me.zero.client.api.exception.ActionNotValidException;

import java.util.Arrays;

/**
 * Utils that the Client API uses
 *
 * @since 1.0
 *
 * Created by Brady on 1/20/2017.
 */
public class ClientUtils {

    /**
     * Concatenates an array of generic arrays
     *
     * @param arrays The arrays being concatenated
     * @return The concatenated array
     */
    public static <T> T[] concat(T[]... arrays) {
        if (arrays.length < 2)
            throw new ActionNotValidException("At least 2 arrays should be supplied");

        T[] result = arrays[0];
        for (int i = 1; i < arrays.length; i++) {
            result = concat(result, arrays[i]);
        }

        return result;
    }

    /**
     * Concatenates 2 generic arrays
     *
     * @param first The first array
     * @param second The seccond array
     * @return The concatenated array
     */
    public static <T> T[] concat(T[] first, T[] second) {
        T[] result = Arrays.copyOf(first, first.length + second.length);
        System.arraycopy(second, 0, result, first.length, second.length);
        return result;
    }

    /**
     * Checks if a generic list contains any null members.
     *
     * @param members The Members to be Checked
     */
    public static <T> boolean containsNull(T... members) {
        for (T member : members)
            if (member == null)
                return true;
        return false;
    }
}

@@ -390,32 +390,49 @@
 d array%0A     */%0A
+    @SafeVarargs%0A
     public stati
@@ -462,17 +462,16 @@
  arrays)
- 
 %7B%0A      
@@ -681,315 +681,166 @@
     
-result = concat(result, arrays%5Bi%5D);%0A        %7D%0A%0A        return result;%0A    %7D%0A%0A    /**%0A     * Concatenates 2 generic arrays
+T%5B%5D newArray = Arrays.copyOf(result, result.length + arrays%5Bi%5D.length);
 %0A     
-*%0A
      
-* @param first The first array%0A     * @param second The seccond array%0A     * @return The concatenated array%0A     */%0A    public static %3CT%3E T%5B%5D concat(T%5B%5D first, T%5B%5D second) %7B
+  System.arraycopy(arrays%5Bi%5D, 0, newArray, result.length, arrays%5Bi%5D.length);
 %0A   
@@ -836,35 +836,35 @@
 ength);%0A        
-T%5B%5D
+   
  result = Arrays
@@ -861,133 +861,28 @@
 t = 
+new
 Array
-s.copyOf(first, first.length + second.length);%0A        System.arraycopy(second, 0, result, first.length, second.length);
+;%0A        %7D%0A
 %0A   

Combine both concat() methods so that it's only 1 method