mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
对EasyStream中补充peekIdx()方法,mapMulti适配于更高版本JDK
This commit is contained in:
parent
e410b2685e
commit
97ce543b47
@ -208,6 +208,26 @@ public class EasyStreamTest {
|
||||
Assert.assertEquals(Arrays.asList(-1, -1, -1), EasyStream.of(1, 2, 3).parallel().flatMapIdx((e, i) -> EasyStream.of(i)).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPeek(){
|
||||
EasyStream.of("one", "two", "three", "four")
|
||||
.filter(e -> e.length() == 4)
|
||||
.peek(e -> Assert.assertEquals("four", e))
|
||||
.map(String::toUpperCase)
|
||||
.peek(e -> Assert.assertEquals("FOUR", e))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPeekIdx(){
|
||||
EasyStream.of("one", "two", "three", "four")
|
||||
.filter(e -> e.length() == 4)
|
||||
.peekIdx((e,i) -> Assert.assertEquals("four:0", e + ":" + i))
|
||||
.map(String::toUpperCase)
|
||||
.peekIdx((e,i) -> Assert.assertEquals("FOUR:0", e + ":" + i))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlat() {
|
||||
final List<Integer> list = Arrays.asList(1, 2, 3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user