package info.ebenoit.ebul.func; import java.util.function.ToLongFunction; /** * This interface supports a {@link ToLongFunction} that can throw checked exceptions. Checked exceptions are * transmitted using a {@link FunctionException} runtime exception. * * @author E. BenoƮt */ @FunctionalInterface public interface ThrowingToLongFunction< T > extends ToLongFunction< T > { /** * Applies this function to the given argument. * * @param t * the argument * @return the result * @throws FunctionException * if a checked exception occurs */ @Override default long applyAsLong( final T t ) { try { return this.throwingApplyAsLong( t ); } catch ( final RuntimeException e ) { throw e; } catch ( final Throwable e ) { throw new FunctionException( e ); } } /** * Applies this function to the given argument. * * @param t * the argument * @return the result * @throws Throwable * any exception */ public long throwingApplyAsLong( T t ) throws Throwable; }