mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
test: add lambada test
This commit is contained in:
parent
d20377c049
commit
848d709140
@ -35,6 +35,10 @@ public class LambdaUtil {
|
||||
private static final Map<Class<?>, Class<?>> implClassMap = new ConcurrentHashMap<>();
|
||||
private static final Map<Class<?>, QueryColumn> queryColumnMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static Map<Class<?>, String> getFieldNameMap() {
|
||||
return fieldNameMap;
|
||||
}
|
||||
|
||||
public static <T> String getFieldName(LambdaGetter<T> getter) {
|
||||
return MapUtil.computeIfAbsent(fieldNameMap, getter.getClass(), aClass -> {
|
||||
SerializedLambda lambda = getSerializedLambda(getter);
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package com.mybatisflex.core.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LambdaUtilTest {
|
||||
|
||||
@Test
|
||||
public void testIssue516() {
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
LambdaUtil.getFieldName(TestAccount::getName);
|
||||
}
|
||||
|
||||
Assert.assertEquals(LambdaUtil.getFieldNameMap().size(), 1);
|
||||
System.out.println("testIssue516");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.mybatisflex.core.util;
|
||||
|
||||
public class TestAccount {
|
||||
|
||||
private String name;
|
||||
private int age;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user