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

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);
		};
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy