mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
:trollface: 优化toTree性能,抽取到CollectorUtil中
This commit is contained in:
@@ -182,7 +182,7 @@ public class EasyStreamTest {
|
||||
Assert.assertEquals(collect2, distinctBy2);
|
||||
|
||||
Assert.assertEquals(
|
||||
4, EasyStream.of(1, 2, 2, null, 3, null).parallel(true).distinct(t -> Objects.isNull(t) ? null : t.toString()).sequential().count()
|
||||
4, EasyStream.of(1, 2, 2, null, 3, null).parallel(true).distinct(t -> Objects.isNull(t) ? null : t.toString()).sequential().count()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ public class EasyStreamTest {
|
||||
Student.builder().id(8L).name("jobob").parentId(5L).build()
|
||||
)
|
||||
// just 4 lambda ,top by condition
|
||||
.toTree(Student::getId, Student::getParentId, Student::setChildren, Student::getMatchParent);
|
||||
.toTree(Student::getId, Student::getParentId, Student::setChildren, s -> BooleanUtil.isTrue(s.getMatchParent()));
|
||||
Assert.assertEquals(asList(
|
||||
Student.builder().id(1L).name("dromara").matchParent(true)
|
||||
.children(asList(Student.builder().id(3L).name("hutool").parentId(1L)
|
||||
@@ -547,10 +547,6 @@ public class EasyStreamTest {
|
||||
public Student() {
|
||||
// this is an accessible parameterless constructor.
|
||||
}
|
||||
|
||||
public Boolean getMatchParent() {
|
||||
return BooleanUtil.isTrue(matchParent);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user