Initial import
Contains POM (probably incomplete) as well as all Throwing versions of java.util.function interfaces + the Runnable interface.
This commit is contained in:
commit
ec2c870f7b
48 changed files with 2427 additions and 0 deletions
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/.metadata/*
|
||||
|
||||
/**/.classpath
|
||||
/**/.project
|
||||
/**/.settings/
|
||||
|
||||
/**/log/
|
||||
/**/target/
|
||||
/**/*.log
|
||||
|
||||
/**/.attach_pid*
|
||||
|
||||
/**/pom.xml.versionsBackup
|
39
pom.xml
Normal file
39
pom.xml
Normal file
|
@ -0,0 +1,39 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>info.ebenoit</groupId>
|
||||
<artifactId>ebul-func</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>E.B.'s utility libraries - Functional interfaces</name>
|
||||
<description>Various utilities related to Java 8's functional interfaces. This includes interfaces for functions that can throw exceptions.</description>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU Lesser General Public License, version 3.0</name>
|
||||
<url>http://www.gnu.org/licenses/lgpl-3.0.en.html</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<organization>
|
||||
<name>Emmanuel Benoît</name>
|
||||
<url>http://www.ebenoit.info</url>
|
||||
</organization>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
27
src/main/java/info/ebenoit/ebul/func/FunctionException.java
Normal file
27
src/main/java/info/ebenoit/ebul/func/FunctionException.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
/**
|
||||
* Runtime exception thrown by Throwing* functional interfaces. Carries the cause of the problem.
|
||||
*
|
||||
* @author <a href="mailto:ebenoit@ebenoit.info">E. Benoît</a>
|
||||
*/
|
||||
public class FunctionException
|
||||
extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -2690556374343638022L;
|
||||
|
||||
|
||||
/**
|
||||
* Initialises the exception from a cause
|
||||
*
|
||||
* @param cause
|
||||
* the exception that happened while the function was being executed.
|
||||
*/
|
||||
public FunctionException( final Throwable cause )
|
||||
{
|
||||
super( "checked exception in function" , cause );
|
||||
}
|
||||
|
||||
}
|
56
src/main/java/info/ebenoit/ebul/func/ThrowingBiConsumer.java
Normal file
56
src/main/java/info/ebenoit/ebul/func/ThrowingBiConsumer.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link BiConsumer} that can throw checked exceptions. Checked exceptions are then
|
||||
* transmitted using a {@link FunctionException} runtime exception.
|
||||
*
|
||||
* @author <a href="mailto:ebenoit@ebenoit.info">E. Benoît</a>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ThrowingBiConsumer< T , U >
|
||||
extends BiConsumer< T , U >
|
||||
{
|
||||
|
||||
/**
|
||||
* Performs the operation on the given arguments, or throws a {@link FunctionException} if a checked exception
|
||||
* occurs.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @throws FunctionException
|
||||
* if any checked exception occurs during the function's execution
|
||||
*/
|
||||
@Override
|
||||
default void accept( final T t , final U u )
|
||||
{
|
||||
try {
|
||||
this.throwingAccept( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation on the given arguments, or throws an arbitrary exception
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public void throwingAccept( T t , U u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
57
src/main/java/info/ebenoit/ebul/func/ThrowingBiFunction.java
Normal file
57
src/main/java/info/ebenoit/ebul/func/ThrowingBiFunction.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link BiFunction} 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 ThrowingBiFunction< T , U , R >
|
||||
extends BiFunction< T , U , R >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default R apply( final T t , final U u )
|
||||
{
|
||||
try {
|
||||
return this.throwingApply( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public R throwingApply( T t , U u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link BiPredicate} 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 ThrowingBiPredicate< T , U >
|
||||
extends BiPredicate< T , U >
|
||||
{
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first input argument
|
||||
* @param u
|
||||
* the second input argument
|
||||
* @return <code>true</code> if the input arguments match the predicate, otherwise <code>false</code>
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurred during evaluation
|
||||
*/
|
||||
@Override
|
||||
default boolean test( final T t , final U u )
|
||||
{
|
||||
try {
|
||||
return this.throwingTest( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first input argument
|
||||
* @param u
|
||||
* the second input argument
|
||||
* @return <code>true</code> if the input arguments match the predicate, otherwise <code>false</code>
|
||||
* @throws Throwable
|
||||
* any checked exception
|
||||
*/
|
||||
public boolean throwingTest( T t , U u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.BinaryOperator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link BinaryOperator} 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 ThrowingBinaryOperator< T >
|
||||
extends BinaryOperator< T >
|
||||
{
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default T apply( final T t , final T u )
|
||||
{
|
||||
try {
|
||||
return this.throwingApply( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public T throwingApply( T t , T u )
|
||||
throws Throwable;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link BooleanSupplier} 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 ThrowingBooleanSupplier
|
||||
extends BooleanSupplier
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets a result
|
||||
*
|
||||
* @return a result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurred
|
||||
*/
|
||||
@Override
|
||||
default boolean getAsBoolean( )
|
||||
{
|
||||
try {
|
||||
return this.throwingGetAsBoolean( );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a result
|
||||
*
|
||||
* @return a result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public boolean throwingGetAsBoolean( )
|
||||
throws Throwable;
|
||||
|
||||
}
|
52
src/main/java/info/ebenoit/ebul/func/ThrowingConsumer.java
Normal file
52
src/main/java/info/ebenoit/ebul/func/ThrowingConsumer.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link Consumer} 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 ThrowingConsumer< T >
|
||||
extends Consumer< T >
|
||||
{
|
||||
|
||||
/**
|
||||
* Performs the operation on the given argument, or throws a {@link FunctionException} if a checked exception
|
||||
* occurs.
|
||||
*
|
||||
* @param t
|
||||
* the input argument
|
||||
* @throws FunctionException
|
||||
* if any exception occurs during the function's execution
|
||||
*/
|
||||
@Override
|
||||
default void accept( final T t )
|
||||
{
|
||||
try {
|
||||
this.throwingAccept( t );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation on the given argument, or throws an exception.
|
||||
*
|
||||
* @param t
|
||||
* the input argument
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public void throwingAccept( T t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.DoubleBinaryOperator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link DoubleBinaryOperator} 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 ThrowingDoubleBinaryOperator
|
||||
extends DoubleBinaryOperator
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default double applyAsDouble( final double t , final double u )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsDouble( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public double throwingApplyAsDouble( double t , double u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.DoubleConsumer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link DoubleConsumer} 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 ThrowingDoubleConsumer
|
||||
extends DoubleConsumer
|
||||
{
|
||||
|
||||
/**
|
||||
* Performs the operation on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the input argument
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs during the operation's execution
|
||||
*/
|
||||
@Override
|
||||
default void accept( final double t )
|
||||
{
|
||||
try {
|
||||
this.throwingAccept( t );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the input argument
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public void throwingAccept( double t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.DoubleFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link DoubleFunction} 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 ThrowingDoubleFunction< R >
|
||||
extends DoubleFunction< R >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default R apply( final double t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApply( 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 R throwingApply( double t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.DoublePredicate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link DoublePredicate} 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 ThrowingDoublePredicate
|
||||
extends DoublePredicate
|
||||
{
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return <code>true</code> if the input argument matches the predicate, otherwise <code>false</code>
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default boolean test( final double t )
|
||||
{
|
||||
try {
|
||||
return this.throwingTest( t );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return <code>true</code> if the input argument matches the predicate, otherwise <code>false</code>
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public boolean throwingTest( double t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link DoubleSupplier} 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 ThrowingDoubleSupplier
|
||||
extends DoubleSupplier
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets a result, or throws a {@link FunctionException} if an exception occurs.
|
||||
*
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if any exception occurs during the function's execution
|
||||
*/
|
||||
@Override
|
||||
default double getAsDouble( )
|
||||
{
|
||||
try {
|
||||
return this.throwingGetAsDouble( );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a result or throws an exception
|
||||
*
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public double throwingGetAsDouble( )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.DoubleToIntFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link DoubleToIntFunction} 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 ThrowingDoubleToIntFunction
|
||||
extends DoubleToIntFunction
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default int applyAsInt( final double t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsInt( 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 int throwingApplyAsInt( double t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.DoubleToLongFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link DoubleToLongFunction} 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 ThrowingDoubleToLongFunction
|
||||
extends DoubleToLongFunction
|
||||
{
|
||||
|
||||
/**
|
||||
* 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 double 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
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
public long throwingApplyAsLong( double t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.DoubleUnaryOperator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link DoubleUnaryOperator} 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 ThrowingDoubleUnaryOperator
|
||||
extends DoubleUnaryOperator
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default double applyAsDouble( final double t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsDouble( 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 first argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public double throwingApplyAsDouble( double t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
53
src/main/java/info/ebenoit/ebul/func/ThrowingFunction.java
Normal file
53
src/main/java/info/ebenoit/ebul/func/ThrowingFunction.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link Function} 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 ThrowingFunction< T , R >
|
||||
extends Function< T , R >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default R apply( final T t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApply( 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 R throwingApply( T t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.IntBinaryOperator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link IntBinaryOperator} 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 ThrowingIntBinaryOperator
|
||||
extends IntBinaryOperator
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default int applyAsInt( final int t , final int u )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsInt( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public int throwingApplyAsInt( int t , int u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link IntConsumer} 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 ThrowingIntConsumer
|
||||
extends IntConsumer
|
||||
{
|
||||
|
||||
/**
|
||||
* Performs the operation on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the input argument
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs during the operation's execution
|
||||
*/
|
||||
@Override
|
||||
default void accept( final int t )
|
||||
{
|
||||
try {
|
||||
this.throwingAccept( t );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the input argument
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public void throwingAccept( int t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.IntFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link IntFunction} 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 ThrowingIntFunction< R >
|
||||
extends IntFunction< R >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default R apply( final int t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApply( 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 R throwingApply( int t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.IntPredicate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link IntPredicate} 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 ThrowingIntPredicate
|
||||
extends IntPredicate
|
||||
{
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return <code>true</code> if the input argument matches the predicate, otherwise <code>false</code>
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default boolean test( final int t )
|
||||
{
|
||||
try {
|
||||
return this.throwingTest( t );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return <code>true</code> if the input argument matches the predicate, otherwise <code>false</code>
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public boolean throwingTest( int t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link IntSupplier} 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 ThrowingIntSupplier
|
||||
extends IntSupplier
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets a result, or throws a {@link FunctionException} if an exception occurs.
|
||||
*
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if any exception occurs during the function's execution
|
||||
*/
|
||||
@Override
|
||||
default int getAsInt( )
|
||||
{
|
||||
try {
|
||||
return this.throwingGetAsInt( );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a result or throws an exception
|
||||
*
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public int throwingGetAsInt( )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.IntToDoubleFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link IntToDoubleFunction} 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 ThrowingIntToDoubleFunction
|
||||
extends IntToDoubleFunction
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default double applyAsDouble( final int t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsDouble( 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 double throwingApplyAsDouble( int t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.IntToLongFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link IntToLongFunction} 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 ThrowingIntToLongFunction
|
||||
extends IntToLongFunction
|
||||
{
|
||||
|
||||
/**
|
||||
* 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 int 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
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
public long throwingApplyAsLong( int t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.IntUnaryOperator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link IntUnaryOperator} 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 ThrowingIntUnaryOperator
|
||||
extends IntUnaryOperator
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default int applyAsInt( final int t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsInt( 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 first argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public int throwingApplyAsInt( int t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.LongBinaryOperator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link LongBinaryOperator} 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 ThrowingLongBinaryOperator
|
||||
extends LongBinaryOperator
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default long applyAsLong( final long t , final long u )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsLong( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public long throwingApplyAsLong( long t , long u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.LongConsumer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link LongConsumer} 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 ThrowingLongConsumer
|
||||
extends LongConsumer
|
||||
{
|
||||
|
||||
/**
|
||||
* Performs the operation on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the input argument
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs during the operation's execution
|
||||
*/
|
||||
@Override
|
||||
default void accept( final long t )
|
||||
{
|
||||
try {
|
||||
this.throwingAccept( t );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the input argument
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public void throwingAccept( long t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link LongFunction} 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 ThrowingLongFunction< R >
|
||||
extends LongFunction< R >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default R apply( final long t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApply( 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 R throwingApply( long t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.LongPredicate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link LongPredicate} 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 ThrowingLongPredicate
|
||||
extends LongPredicate
|
||||
{
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return <code>true</code> if the input argument matches the predicate, otherwise <code>false</code>
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default boolean test( final long t )
|
||||
{
|
||||
try {
|
||||
return this.throwingTest( t );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return <code>true</code> if the input argument matches the predicate, otherwise <code>false</code>
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public boolean throwingTest( long t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link LongSupplier} 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 ThrowingLongSupplier
|
||||
extends LongSupplier
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets a result, or throws a {@link FunctionException} if an exception occurs.
|
||||
*
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if any exception occurs during the function's execution
|
||||
*/
|
||||
@Override
|
||||
default long getAsLong( )
|
||||
{
|
||||
try {
|
||||
return this.throwingGetAsLong( );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a result or throws an exception
|
||||
*
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public long throwingGetAsLong( )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.LongToDoubleFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link LongToDoubleFunction} 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 ThrowingLongToDoubleFunction
|
||||
extends LongToDoubleFunction
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default double applyAsDouble( final long t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsDouble( 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 double throwingApplyAsDouble( long t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.LongToIntFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link LongToIntFunction} 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 ThrowingLongToIntFunction
|
||||
extends LongToIntFunction
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default int applyAsInt( final long t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsInt( 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 int throwingApplyAsInt( long t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link LongUnaryOperator} 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 ThrowingLongUnaryOperator
|
||||
extends LongUnaryOperator
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default long applyAsLong( final long 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 first argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public long throwingApplyAsLong( long t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.ObjDoubleConsumer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link ObjDoubleConsumer} that can throw checked exceptions. Checked exceptions are then
|
||||
* transmitted using a {@link FunctionException} runtime exception.
|
||||
*
|
||||
* @author <a href="mailto:ebenoit@ebenoit.info">E. Benoît</a>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ThrowingObjDoubleConsumer< T >
|
||||
extends ObjDoubleConsumer< T >
|
||||
{
|
||||
|
||||
/**
|
||||
* Performs the operation on the given arguments, or throws a {@link FunctionException} if a checked exception
|
||||
* occurs.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @throws FunctionException
|
||||
* if any checked exception occurs during the function's execution
|
||||
*/
|
||||
@Override
|
||||
default void accept( final T t , final double u )
|
||||
{
|
||||
try {
|
||||
this.throwingAccept( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation on the given arguments, or throws an arbitrary exception
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public void throwingAccept( T t , double u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.ObjIntConsumer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link ObjIntConsumer} that can throw checked exceptions. Checked exceptions are then
|
||||
* transmitted using a {@link FunctionException} runtime exception.
|
||||
*
|
||||
* @author <a href="mailto:ebenoit@ebenoit.info">E. Benoît</a>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ThrowingObjIntConsumer< T >
|
||||
extends ObjIntConsumer< T >
|
||||
{
|
||||
|
||||
/**
|
||||
* Performs the operation on the given arguments, or throws a {@link FunctionException} if a checked exception
|
||||
* occurs.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @throws FunctionException
|
||||
* if any checked exception occurs during the function's execution
|
||||
*/
|
||||
@Override
|
||||
default void accept( final T t , final int u )
|
||||
{
|
||||
try {
|
||||
this.throwingAccept( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation on the given arguments, or throws an arbitrary exception
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public void throwingAccept( T t , int u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.ObjLongConsumer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link ObjLongConsumer} that can throw checked exceptions. Checked exceptions are then
|
||||
* transmitted using a {@link FunctionException} runtime exception.
|
||||
*
|
||||
* @author <a href="mailto:ebenoit@ebenoit.info">E. Benoît</a>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ThrowingObjLongConsumer< T >
|
||||
extends ObjLongConsumer< T >
|
||||
{
|
||||
|
||||
/**
|
||||
* Performs the operation on the given arguments, or throws a {@link FunctionException} if a checked exception
|
||||
* occurs.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @throws FunctionException
|
||||
* if any checked exception occurs during the function's execution
|
||||
*/
|
||||
@Override
|
||||
default void accept( final T t , final long u )
|
||||
{
|
||||
try {
|
||||
this.throwingAccept( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation on the given arguments, or throws an arbitrary exception
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public void throwingAccept( T t , long u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
53
src/main/java/info/ebenoit/ebul/func/ThrowingPredicate.java
Normal file
53
src/main/java/info/ebenoit/ebul/func/ThrowingPredicate.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link Predicate} 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 ThrowingPredicate< T >
|
||||
extends Predicate< T >
|
||||
{
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return <code>true</code> if the input argument matches the predicate, otherwise <code>false</code>
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default boolean test( final T t )
|
||||
{
|
||||
try {
|
||||
return this.throwingTest( t );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return <code>true</code> if the input argument matches the predicate, otherwise <code>false</code>
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public boolean throwingTest( T t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
42
src/main/java/info/ebenoit/ebul/func/ThrowingRunnable.java
Normal file
42
src/main/java/info/ebenoit/ebul/func/ThrowingRunnable.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link Runnable} 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 ThrowingRunnable
|
||||
extends Runnable
|
||||
{
|
||||
|
||||
/**
|
||||
* Executes the procedure
|
||||
*
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default void run( )
|
||||
{
|
||||
try {
|
||||
this.throwingRun( );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes the procedure, may throw any exception
|
||||
*
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public void throwingRun( )
|
||||
throws Throwable;
|
||||
}
|
49
src/main/java/info/ebenoit/ebul/func/ThrowingSupplier.java
Normal file
49
src/main/java/info/ebenoit/ebul/func/ThrowingSupplier.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link Supplier} 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 ThrowingSupplier< T >
|
||||
extends Supplier< T >
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets a result, or throws a {@link FunctionException} if an exception occurs.
|
||||
*
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if any exception occurs during the function's execution
|
||||
*/
|
||||
@Override
|
||||
default T get( )
|
||||
{
|
||||
try {
|
||||
return this.throwingGet( );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a result or throws an exception
|
||||
*
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public T throwingGet( )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.ToDoubleBiFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link ToDoubleBiFunction} 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 ThrowingToDoubleBiFunction< T , U >
|
||||
extends ToDoubleBiFunction< T , U >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default double applyAsDouble( final T t , final U u )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsDouble( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public double throwingApplyAsDouble( T t , U u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.ToDoubleFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link ToDoubleFunction} 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 ThrowingToDoubleFunction< T >
|
||||
extends ToDoubleFunction< T >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default double applyAsDouble( final T t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsDouble( 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 double throwingApplyAsDouble( T t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.ToIntBiFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link ToIntBiFunction} 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 ThrowingToIntBiFunction< T , U >
|
||||
extends ToIntBiFunction< T , U >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default int applyAsInt( final T t , final U u )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsInt( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public int throwingApplyAsInt( T t , U u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.ToIntFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link ToIntFunction} 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 ThrowingToIntFunction< T >
|
||||
extends ToIntFunction< T >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default int applyAsInt( final T t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsInt( 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 int throwingApplyAsInt( T t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.ToLongBiFunction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link ToLongBiFunction} 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 ThrowingToLongBiFunction< T , U >
|
||||
extends ToLongBiFunction< T , U >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default long applyAsLong( final T t , final U u )
|
||||
{
|
||||
try {
|
||||
return this.throwingApplyAsLong( t , u );
|
||||
} catch ( final RuntimeException e ) {
|
||||
throw e;
|
||||
} catch ( final Throwable e ) {
|
||||
throw new FunctionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param t
|
||||
* the first argument
|
||||
* @param u
|
||||
* the second argument
|
||||
* @return the result
|
||||
* @throws Throwable
|
||||
* any exception
|
||||
*/
|
||||
public long throwingApplyAsLong( T t , U u )
|
||||
throws Throwable;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
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 <a href="mailto:ebenoit@ebenoit.info">E. Benoît</a>
|
||||
*/
|
||||
@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;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package info.ebenoit.ebul.func;
|
||||
|
||||
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports a {@link UnaryOperator} 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 ThrowingUnaryOperator< T >
|
||||
extends UnaryOperator< T >
|
||||
{
|
||||
|
||||
/**
|
||||
* Applies this function to the given argument.
|
||||
*
|
||||
* @param t
|
||||
* the argument
|
||||
* @return the result
|
||||
* @throws FunctionException
|
||||
* if a checked exception occurs
|
||||
*/
|
||||
@Override
|
||||
default T apply( final T t )
|
||||
{
|
||||
try {
|
||||
return this.throwingApply( 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 T throwingApply( T t )
|
||||
throws Throwable;
|
||||
|
||||
}
|
8
src/main/java/info/ebenoit/ebul/func/package-info.java
Normal file
8
src/main/java/info/ebenoit/ebul/func/package-info.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* This package contains various utilities to be used along with {@link java.util.function}. This includes support for
|
||||
* the float primitive type as well as versions of all interfaces capable of rethrowing checked exceptions as runtime
|
||||
* exceptions.
|
||||
*
|
||||
* @author <a href="mailto:ebenoit@ebenoit.info">E. Benoît</a>
|
||||
*/
|
||||
package info.ebenoit.ebul.func;
|
Loading…
Reference in a new issue