Change Lists.partition() argument order to match Guava's

- May as well match what they have in terms of arg order
- Change from interface to class might be better
This commit is contained in:
robin.bygrave
2023-08-17 15:36:03 +12:00
parent 9bcd189730
commit bab9be0228
3 changed files with 19 additions and 13 deletions
+10 -4
View File
@@ -6,17 +6,23 @@ import java.util.List;
/**
* Helper methods for Lists.
*/
public interface Lists {
public final class Lists {
private Lists() {
}
/**
* Partition the source List into sub-lists with a maximum size.
* <p>
* The sub-lists will all be the max size except for the last sub-list
* which can potentially be smaller.
*
* @param max The max size of each partition
* @param source The source list
* @param max The max size of each partition
* @param <T> The list element type
* @return List of partitions
* @return List of sub-list partitions
*/
static <T> List<List<T>> partition(int max, List<T> source) {
public static <T> List<List<T>> partition(List<T> source, int max) {
final int totalCount = source.size();
if (totalCount <= max) {
return List.of(source);