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

com.jnape.palatable.lambda.functions.specialized.checked.CheckedFn1 Maven / Gradle / Ivy

package com.jnape.palatable.lambda.functions.specialized.checked;

import com.jnape.palatable.lambda.functions.Fn1;

import static com.jnape.palatable.lambda.functions.specialized.checked.Runtime.throwChecked;

/**
 * Specialized {@link Fn1} that can throw checked exceptions.
 *
 * @param  The input type
 * @param  The output type
 * @see CheckedSupplier
 * @see Fn1
 */
@FunctionalInterface
public interface CheckedFn1 extends Fn1 {

    @Override
    default B apply(A a) {
        try {
            return checkedApply(a);
        } catch (Throwable t) {
            throw throwChecked(t);
        }
    }

    /**
     * A version of {@link Fn1} that can throw checked exceptions.
     *
     * @param a the argument
     * @return the result of the function application
     * @throws Exception any exception thrown by the function application
     */
    B checkedApply(A a) throws Exception;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy