
co.unruly.matchers.function.SerializedLambdaResolvable Maven / Gradle / Ivy
package co.unruly.matchers.function;
import java.io.Serializable;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
interface SerializedLambdaResolvable extends Serializable {
default SerializedLambda asSerializedLambda() {
try {
Method replaceMethod = getClass().getDeclaredMethod("writeReplace");
replaceMethod.setAccessible(true);
return (SerializedLambda) replaceMethod.invoke(this);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new RuntimeException(e.getClass().getSimpleName() + ": '" + e.getMessage() + "'", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy