package com.github.markozajc.functions.exceptionable; import static com.github.markozajc.functions.exceptionable.Utilities.asUnchecked; import com.github.markozajc.functions.ObjIntFunction; /** * Variant of {@link ObjIntFunction} capable of throwing a generic {@link Throwable}. * * @author Marko Zajc * * @param * the type of the first argument to the function * @param * the type of the result of the function * @param * {@link Throwable} type */ @FunctionalInterface public interface EObjIntFunction extends ObjIntFunction { @Override default R apply(T t, int i) { try { return applyChecked(t, i); } catch (Throwable e) { // NOSONAR can't catch generic exceptions throw asUnchecked(e); } } /** * Same as {@link #apply(Object, int)}, but throws a checked exception. * * @param t * the first function argument * @param i * the second ({@code int}) function argument * * @return the function result * * @throws E * the defined exception type */ R applyChecked(T t, int i) throws E; }