public static <T> Object newPrimitiveArray(Class<T> type) {

    if (type.equals(byte.class)) {
      return newRandomByteArray();
    } else if (type.equals(int.class)) {
      return newRandomIntArray();
    } else if (type.equals(double.class)) {
      return newRandomDoubleArray();
    } else if (type.equals(char.class)) {
      return newRandomCharArray();
    } else if (type.equals(boolean.class)) {
      return newRandomBooleanArray();
    } else if (type.equals(long.class)) {
      return newRandomLongArray();
    } else if (type.equals(float.class)) {
      return newRandomFloatArray();
    } else if (type.equals(short.class)) {
      return newRandomShortArray();
    }

    throw new RuntimeException("Not a primitive type: " + type.getCanonicalName());
  }