Float functions - Throwing* variants
Added variants of the float primitive functions with support for checked exception.
This commit is contained in:
parent
ea2fc5a632
commit
52e685311a
15 changed files with 740 additions and 0 deletions
src/main/java/info/ebenoit/ebul/func
|
@ -0,0 +1,49 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link DoubleToFloatFunction} that can throw checked exceptions. Checked exceptions are
|
||||
* transmitted using a {@link FunctionException} runtime exception.
|
||||
*
|
||||
* @author <a href="mailto:ebenoit@ebenoit.info">E. Benoît</a>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ThrowingDoubleToFloatFunction
|
||||
extends DoubleToFloatFunction
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default float applyAsFloat( final double t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsFloat( 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
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
public float throwingApplyAsFloat( double t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue