mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
30 lines
868 B
Java
30 lines
868 B
Java
import org.junit.jupiter.api.Test;
|
|
import work.slhaf.partner.core.cognation.common.pojo.MemoryResult;
|
|
import work.slhaf.partner.core.cognation.submodule.memory.MemoryCapability;
|
|
|
|
import java.lang.reflect.Proxy;
|
|
import java.util.function.Function;
|
|
|
|
public class ReflectionTest {
|
|
|
|
@Test
|
|
public void test1() {
|
|
}
|
|
|
|
@Test
|
|
public void proxyTest() {
|
|
MemoryCapability memory = (MemoryCapability) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{MemoryCapability.class}, (proxy, method, args) -> {
|
|
if ("selectMemory".equals(method.getName())){
|
|
System.out.println(111);
|
|
return new MemoryResult();
|
|
}
|
|
return null;
|
|
});
|
|
memory.selectMemory("111");
|
|
|
|
Function<String, Integer> function = s -> {
|
|
return s.length();
|
|
};
|
|
}
|
|
}
|