This commit is contained in:
ran.shang
2025-06-11 09:42:13 +08:00
commit 7e38b8d971
1935 changed files with 132836 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package com.newyetai.common.functions;
import java.io.Serializable;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Method;
import java.util.function.Function;
/**
* @author chenyun
* @description 序列化的Function
* @date 2020/9/16 13:38
*/
@FunctionalInterface
public interface SFunction<T, R> extends Function<T, R>, Serializable {
/**
* 解析function为SerializedLambda
*
* @return
*/
default SerializedLambda serialized() {
try {
Method replaceMethod = getClass().getDeclaredMethod("writeReplace");
replaceMethod.setAccessible(true);
return (SerializedLambda) replaceMethod.invoke(this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}