package de.gurkenlabs.util;

import java.util.logging.Level;
import java.util.logging.Logger;

public final class ArrayUtilities {
  private static final Logger log = Logger.getLogger(ArrayUtilities.class.getName());

  private ArrayUtilities() {
  }

  public static byte[] arrayConcat(final byte[] firstArray, final byte[] secondArray) {
    final int aLen = firstArray.length;
    final int bLen = secondArray.length;
    final byte[] combinedArray = new byte[aLen + bLen];
    System.arraycopy(firstArray, 0, combinedArray, 0, aLen);
    System.arraycopy(secondArray, 0, combinedArray, aLen, bLen);
    return combinedArray;
  }

  public static int[] getIntegerArray(String commaSeparatedIntegers) {
    if (commaSeparatedIntegers == null || commaSeparatedIntegers.isEmpty()) {
      return new int[0];
    }

    final String[] split = commaSeparatedIntegers.split(",");
    int[] integers = new int[split.length];
    if (integers.length == 0) {
      return integers;
    }

    for (int i = 0; i < split.length; i++) {
      String integerString = split[i];
      if (integerString == null || integerString.isEmpty()) {
        continue;
      }

      try {
        integers[i] = Integer.parseInt(integerString);
      } catch (final NumberFormatException e) {
        log.log(Level.SEVERE, e.getMessage(), e);
      }
    }

    return integers;
  }
}

@@ -22,16 +22,41 @@
 .util;%0A%0A
+import java.util.Random;%0A
 import j
@@ -1378,11 +1378,203 @@
 ers;%0A  %7D
+%0A%0A  public static %3CT%3E T getRandom(T%5B%5D arr) %7B%0A    if (arr.length == 0) %7B%0A      return null;%0A    %7D%0A%0A    final int randomIndex = new Random().nextInt(arr.length);%0A    return arr%5BrandomIndex%5D;%0A  %7D
 %0A%7D%0A

Extend ArrayUtilities with a method that gets a random element from the a specified array.