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

org.xblackcat.sjpu.util.function.ToIntBiFunctionEx Maven / Gradle / Ivy

Go to download

Collect of utility classes and interfaces. Currenlty contains: extention of standart functional interfaces (java.util.function.*) which allow to declare thrown exception as type parameter; Simple implementation of LockPool

The newest version!
package org.xblackcat.sjpu.util.function;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.function.ToIntBiFunction;

/**
 * Represents a function that accepts two arguments and produces an int-valued
 * result.  This is the {@code int}-producing primitive specialization for
 * {@link BiFunctionEx}.
 * 

*

This is a functional interface * whose functional method is {@link #applyAsInt(Object, Object)}. * * @param the type of the first argument to the function * @param the type of the second argument to the function * @param the type of exception could be thrown while performing operation * @see BiFunctionEx * @since 1.8 */ @FunctionalInterface public interface ToIntBiFunctionEx { /** * Applies this function to the given arguments. * * @param t the first function argument * @param u the second function argument * @return the function result */ int applyAsInt(T t, U u) throws E; default ToIntFunctionEx fixRight(U u) { return t -> applyAsInt(t, u); } default ToIntFunctionEx fixLeft(T t) { return u -> applyAsInt(t, u); } default IntSupplierEx fix(T t, U u) { return () -> applyAsInt(t, u); } default ToIntBiFunction unchecked(String exceptionText, BiFunction cover) { return unchecked(() -> exceptionText, cover); } default ToIntBiFunction unchecked() { return unchecked(CoveringException::new); } default ToIntBiFunction unchecked(BiFunction cover) { return unchecked(Throwable::getMessage, cover); } default ToIntBiFunction unchecked(Supplier text, BiFunction cover) { return unchecked(e -> text.get(), cover); } default ToIntBiFunction unchecked( Function text, BiFunction cover ) { return (t, u) -> { try { return applyAsInt(t, u); } catch (Throwable e) { throw cover.apply(text.apply(e), e); } }; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy