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

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

There is a newer version: 5.5.0
Show newest version
package com.jnape.palatable.lambda.functions.specialized.checked;

import java.util.function.Supplier;

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

/**
 * Specialized {@link Supplier} that can throw checked exceptions.
 *
 * @param  The exception type
 * @param  The return type
 * @see CheckedFn1
 */
@FunctionalInterface
public interface CheckedSupplier extends Supplier {

    @Override
    default T get() {
        try {
            return checkedGet();
        } catch (Throwable t) {
            throw throwChecked(t);
        }
    }

    /**
     * A version of {@link Supplier#get()} that can throw checked exceptions.
     *
     * @return the supplied result
     * @throws E any exception that can be thrown by this method
     */
    T checkedGet() throws E;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy