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

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

package com.g2forge.alexandria.java.function;

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

	public default void accept(I0 i0, I1 i1, I2 i2) throws T {
		apply(i0, i1, i2);
	}

	public O apply(I0 input0, I1 input1, I2 input2) throws T;

	public default IThrowFunction3 sync(Object lock) {
		if (lock == null) return this;
		return (i0, i1, i2) -> {
			synchronized (lock) {
				return apply(i0, i1, i2);
			}
		};
	}

	public default IThrowConsumer3 toConsumer() {
		return this::apply;
	}

	public default <_O> IThrowFunction3 toFunction(_O retVal) {
		return (i0, i1, i2) -> {
			apply(i0, i1, i2);
			return retVal;
		};
	}

	public default IFunction3 wrap(IFunction1 wrapper) {
		return (i0, i1, i2) -> {
			try {
				return apply(i0, i1, i2);
			} catch (Throwable throwable) {
				throw wrapper.apply(throwable);
			}
		};
	}

	public default IThrowFunction3 wrap(IRunnable pre, IRunnable post) {
		return (i0, i1, i2) -> {
			pre.run();
			try {
				return apply(i0, i1, i2);
			} finally {
				post.run();
			}
		};
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy