org.codefilarete.tool.Lambdas Maven / Gradle / Ivy
package org.codefilarete.tool;
import java.util.function.Function;
/**
* @author Guillaume Mary
*/
public class Lambdas {
/**
* Run some code before another
* @param surrogate the code to execute
* @param runnable the code to be executed before
* @param input parameter type
* @param ouput parameter type
* @return the result of surrogate.apply()
*/
public static Function before(Function surrogate, Runnable runnable) {
return i -> {
runnable.run();
return surrogate.apply(i);
};
}
}