com.jnape.palatable.lambda.functions.specialized.checked.CheckedSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lambda Show documentation
Show all versions of lambda Show documentation
Functional patterns for Java
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