List<LazadaTrackingDataTO> dataSourceList = new ArrayList<LazadaTrackingDataTO>();
if (packages.size() > 1000) { int i = 0, j = 1000; while (true) { if (j > packages.size()) { j =packages.size(); } LazadaTrackingDataTO data = new LazadaTrackingDataTO(); data.setPackages(packages.subList(i, j)); logger.debug("DEBUG List, cut the List from i" + i + " to " + j); dataSourceList.add(data); if (j == packages.size()) { break; } i = j; j = j + 1000; } } else { LazadaTrackingDataTO data1 = new LazadaTrackingDataTO(); data1.setPackages(packages); dataSourceList.add(data1); }