This commit is contained in:
Looly 2023-02-24 20:56:14 +08:00
parent 76c42d49c7
commit 8db58cedde

View File

@ -29,7 +29,6 @@ import java.util.function.Function;
*/ */
public class LambdaFactoryTest { public class LambdaFactoryTest {
// @Test
@Test @Test
public void testMethodNotMatch() { public void testMethodNotMatch() {
try { try {
@ -39,6 +38,7 @@ public class LambdaFactoryTest {
} }
} }
@SuppressWarnings("unchecked")
@Test @Test
public void buildLambdaTest() { public void buildLambdaTest() {
final Something something = new Something(); final Something something = new Something();
@ -49,6 +49,7 @@ public class LambdaFactoryTest {
final Function<Something, Long> get12 = LambdaFactory.build(Function.class, Something.class, "getId"); final Function<Something, Long> get12 = LambdaFactory.build(Function.class, Something.class, "getId");
Assert.assertEquals(get11, get12); Assert.assertEquals(get11, get12);
// 通过LambdaFactory模拟创建一个getId方法的Lambda句柄函数通过调用这个函数实现方法调用
Assert.assertEquals(something.getId(), get11.apply(something)); Assert.assertEquals(something.getId(), get11.apply(something));
final String name = "sname"; final String name = "sname";
@ -136,6 +137,7 @@ public class LambdaFactoryTest {
* <p>proxy 运行100000000次耗时 1117192600 NANOSECONDS * <p>proxy 运行100000000次耗时 1117192600 NANOSECONDS
* <p>-------------------------------------------- * <p>--------------------------------------------
*/ */
@SuppressWarnings({"rawtypes", "unchecked", "Convert2MethodRef"})
@Test @Test
@SneakyThrows @SneakyThrows
public void lambdaGetPerformanceTest() { public void lambdaGetPerformanceTest() {
@ -211,6 +213,7 @@ public class LambdaFactoryTest {
* <p>proxy 运行100000000次耗时 1169452400 NANOSECONDS * <p>proxy 运行100000000次耗时 1169452400 NANOSECONDS
* <p>-------------------------------------------- * <p>--------------------------------------------
*/ */
@SuppressWarnings({"rawtypes", "unchecked"})
@Test @Test
@SneakyThrows @SneakyThrows
public void lambdaSetPerformanceTest() { public void lambdaSetPerformanceTest() {
@ -246,6 +249,7 @@ public class LambdaFactoryTest {
loop(count, tasks); loop(count, tasks);
} }
@SuppressWarnings("rawtypes")
@SneakyThrows @SneakyThrows
private void loop(final int count, final Task... tasks) { private void loop(final int count, final Task... tasks) {
Arrays.stream(tasks) Arrays.stream(tasks)
@ -265,6 +269,7 @@ public class LambdaFactoryTest {
System.out.println("--------------------------------------------"); System.out.println("--------------------------------------------");
} }
@SuppressWarnings({"InnerClassMayBeStatic", "FieldMayBeFinal"})
@Getter @Getter
private class Task { private class Task {
private String name; private String name;