All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.co.probablyfine.matchers.function.SerializedLambdaResolvable Maven / Gradle / Ivy

The newest version!
package uk.co.probablyfine.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