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

net.mintern.functions.unary.checked.ShortToObjE Maven / Gradle / Ivy

There is a newer version: 2.0
Show newest version
package net.mintern.functions.unary.checked;

/**
 * An operation of type {@code (short) -> R}.
 *
 * @param  the type of the return value
 * @param  the {@code Exception} type that the operation may throw
 */
@FunctionalInterface
public interface ShortToObjE {

    /**
     * Performs this operation.
     *
     * @param sh the argument
     * @return the result of the operation
     * @throws E if the operation cannot be completed
     */
    R call(short sh) throws E;

    /**
     * Binds {@code (sh)} to {@code f}, returning a new function
     * of type {@code () -> R}.
     *
     * @param  the type of the return value
     * @param  the {@code Exception} type that the operation may throw
     * @param f the unbound function
     * @param sh the argument
     * @return a new function {@code () -> R} that calls
     *      {@code f.call(sh)} and returns the result.
     */
    @SuppressWarnings("unchecked") // maven spuriously warns about a type error in this case
    static  net.mintern.functions.nullary.checked.NilToObjE
    bind(ShortToObjE f, short sh) {
        return () -> f.call(sh);
    }

    /**
     * Binds {@code (sh)} to {@code this}, returning a new function
     * of type {@code () -> R}.
     *
     * @param sh the argument
     * @return a new function {@code () -> R} that calls
     *      {@code this.call(sh)} and returns the result.
     */
    default net.mintern.functions.nullary.checked.NilToObjE bind(short sh) {
        return ShortToObjE.bind(this, sh);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy