class ApplicationExporter {

  public static <T> Set<List<T>> partition(List<T> _list, int _num)
      throws IllegalArgumentException {
    final Set<List<T>> parts = new HashSet<List<T>>();

    // Number of parts must be > 0
    if (_num < 1)
      throw new IllegalArgumentException(
          "Number of partitions must be greater than 0 but is [" + _num + "]");

    // No list
    else if (_list == null)
      ;

    // Return 1 part only
    else if (_list.size() < _num) parts.add(_list);

    // Create sublists
    else {
      final int size = (int) Math.floor((double) _list.size() / (double) _num);
      int i, min, max;

      // Create _partition_no -1 parts
      for (i = 0; i < _num - 1; i++) {
        min = i * size;
        max = Math.min((i + 1) * size, _list.size());
        if (max >= min) {
          parts.add(_list.subList(min, max));
        }
      }

      // Create last part with remaining elements
      min = i * size;
      max = Math.min((_num + 1) * size, _list.size());
      if (max >= min) {
        parts.add(_list.subList(min, max));
      }
    }
    return parts;
  }

}