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

com.g2forge.alexandria.java.function.IFunction2 Maven / Gradle / Ivy

There is a newer version: 0.0.18
Show newest version
package com.g2forge.alexandria.java.function;

import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Supplier;

@FunctionalInterface
public interface IFunction2 extends BiFunction, IFunction {
	public static  IFunction2 create(IFunction2 function) {
		return function;
	}

	public default IFunction1 compose0(Supplier before) {
		Objects.requireNonNull(before);
		return i1 -> apply(before.get(), i1);
	}

	public default IFunction1 compose1(Supplier before) {
		Objects.requireNonNull(before);
		return i0 -> apply(i0, before.get());
	}

	public default IFunction1 compute0(IFunction1 i0) {
		return i1 -> this.apply(i0.apply(i1), i1);
	}

	public default IFunction1 compute1(IFunction1 i1) {
		return i0 -> this.apply(i0, i1.apply(i0));
	}

	public default IFunction1 curry0(I0 input0) {
		return input1 -> apply(input0, input1);
	}

	public default IFunction1 curry1(I1 input1) {
		return input0 -> apply(input0, input1);
	}

	public default IConsumer2 noReturn() {
		return (i0, i1) -> apply(i0, i1);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy