fix method

This commit is contained in:
Looly
2021-06-16 02:32:12 +08:00
parent ca2952543a
commit 26064f146c
6 changed files with 36 additions and 128 deletions

View File

@@ -40,7 +40,7 @@ public class ListUtilTest {
@Test
public void editTest(){
List<String> a = ListUtil.toLinkedList("1", "2", "3");
final List<String> filter = ListUtil.edit(a, str -> "edit" + str);
final List<String> filter = (List<String>) CollUtil.edit(a, str -> "edit" + str);
Assert.assertEquals("edit1", filter.get(0));
Assert.assertEquals("edit2", filter.get(1));
Assert.assertEquals("edit3", filter.get(2));

View File

@@ -1,8 +1,6 @@
package cn.hutool.core.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Editor;
import cn.hutool.core.lang.Filter;
import org.junit.Assert;
import org.junit.Test;
@@ -79,23 +77,23 @@ public class ArrayUtilTest {
}
@Test
public void filterTest() {
public void filterEditTest() {
Integer[] a = {1, 2, 3, 4, 5, 6};
Integer[] filter = ArrayUtil.filter(a, (Editor<Integer>) t -> (t % 2 == 0) ? t : null);
Integer[] filter = ArrayUtil.edit(a, t -> (t % 2 == 0) ? t : null);
Assert.assertArrayEquals(filter, new Integer[]{2, 4, 6});
}
@Test
public void filterTestForFilter() {
Integer[] a = {1, 2, 3, 4, 5, 6};
Integer[] filter = ArrayUtil.filter(a, (Filter<Integer>) t -> t % 2 == 0);
Integer[] filter = ArrayUtil.filter(a, t -> t % 2 == 0);
Assert.assertArrayEquals(filter, new Integer[]{2, 4, 6});
}
@Test
public void filterTestForEditor() {
public void editTest() {
Integer[] a = {1, 2, 3, 4, 5, 6};
Integer[] filter = ArrayUtil.filter(a, (Editor<Integer>) t -> (t % 2 == 0) ? t * 10 : t);
Integer[] filter = ArrayUtil.edit(a, t -> (t % 2 == 0) ? t * 10 : t);
Assert.assertArrayEquals(filter, new Integer[]{1, 20, 3, 40, 5, 60});
}