diff --git a/ebean-api/src/main/java/io/ebean/Lists.java b/ebean-api/src/main/java/io/ebean/Lists.java index a478877f2..e80aa91fd 100644 --- a/ebean-api/src/main/java/io/ebean/Lists.java +++ b/ebean-api/src/main/java/io/ebean/Lists.java @@ -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. + *
+ * 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 > partition(int max, List
> partition(List
> partitions = Lists.partition(5, List.of());
+ List
> partitions = Lists.partition(List.of(), 5);
assertThat(partitions).hasSize(1);
assertThat(partitions.get(0)).hasSize(0);
}
@Test
void partition_lt() {
- List
> partitions = Lists.partition(5, List.of(1, 2, 3, 4));
+ List
> partitions = Lists.partition(List.of(1, 2, 3, 4), 5);
assertThat(partitions).hasSize(1);
assertThat(partitions.get(0)).hasSize(4);
}
@Test
void partition_eq() {
- List
> partitions = Lists.partition(5, List.of(1, 2, 3, 4, 5));
+ List
> partitions = Lists.partition(List.of(1, 2, 3, 4, 5), 5);
assertThat(partitions).hasSize(1);
assertThat(partitions.get(0)).hasSize(5);
}
@Test
void partition_gt() {
- List
> partitions = Lists.partition(5, List.of(1, 2, 3, 4, 5, 6));
+ List
> partitions = Lists.partition(List.of(1, 2, 3, 4, 5, 6), 5);
assertThat(partitions).hasSize(2);
assertThat(partitions.get(0)).hasSize(5);
assertThat(partitions.get(1)).hasSize(1);
@@ -41,7 +41,7 @@ class ListsTest {
@Test
void partition_gt1_letters() {
- var partitions = Lists.partition(3, List.of("a", "b", "c", "d"));
+ var partitions = Lists.partition(List.of("a", "b", "c", "d"), 3);
assertThat(partitions).hasSize(2);
assertThat(partitions.get(0)).hasSize(3);
assertThat(partitions.get(1)).hasSize(1);
@@ -51,7 +51,7 @@ class ListsTest {
@Test
void partition_gt1a_letters() {
- var partitions = Lists.partition(3, List.of("a", "b", "c", "d", "e"));
+ var partitions = Lists.partition(List.of("a", "b", "c", "d", "e"), 3);
assertThat(partitions).hasSize(2);
assertThat(partitions.get(0)).hasSize(3);
assertThat(partitions.get(1)).hasSize(2);
@@ -61,7 +61,7 @@ class ListsTest {
@Test
void partition_eq2_letters() {
- var partitions = Lists.partition(3, List.of("a", "b", "c", "d", "e", "f"));
+ var partitions = Lists.partition(List.of("a", "b", "c", "d", "e", "f"), 3);
assertThat(partitions).hasSize(2);
assertThat(partitions.get(0)).hasSize(3);
assertThat(partitions.get(1)).hasSize(3);
@@ -71,7 +71,7 @@ class ListsTest {
@Test
void partition_gt2_letters() {
- var partitions = Lists.partition(3, List.of("a", "b", "c", "d", "e", "f", "g"));
+ var partitions = Lists.partition(List.of("a", "b", "c", "d", "e", "f", "g"), 3);
assertThat(partitions).hasSize(3);
assertThat(partitions.get(0)).hasSize(3);
assertThat(partitions.get(1)).hasSize(3);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
index 1d3ac0076..001e5328a 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
@@ -659,7 +659,7 @@ public final class DefaultPersister implements Persister {
return deleteBatch(descriptor, id, idList, transaction, deleteMode);
}
int rows = 0;
- for (List