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

hm.binkley.util.function.ThrowingBiFunction Maven / Gradle / Ivy

The newest version!
package hm.binkley.util.function;

import javax.annotation.Nonnull;
import java.util.function.BiFunction;
import java.util.function.Function;

/**
 * {@code ThrowingBiFunction} is a throwing look-a=like of {@link BiFunction}.  It cannot
 * be a {@code BiFunction} as it takes throwing versions of bi-functions.  Otherwise it is a
 * faithful reproduction.
 *
 * @author B. K. Oxley (binkley)
 */
@SuppressWarnings({"UnusedDeclaration", "JavaDoc"})
@FunctionalInterface
public interface ThrowingBiFunction {
    /** @see BiFunction#apply(Object, Object) */
    R apply(final T t, final U u)
            throws E, InterruptedException;

    /** @see BiFunction#andThen(Function) */
    @Nonnull
    default  ThrowingBiFunction andThen(
            @Nonnull final ThrowingFunction after)
            throws E, InterruptedException {
        return (T t, U u) -> after.apply(apply(t, u));
    }

    /** Creates a facade {@code Function} wrapping this throwing one. */
    default  BiFunction asBiFunction(final Defer defer) {
        return (u, v) -> defer.as(() -> apply(u, v));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy