Package org.wso2.carbon.utils
Class LambdaExceptionUtils
- java.lang.Object
-
- org.wso2.carbon.utils.LambdaExceptionUtils
-
public final class LambdaExceptionUtils extends Object
A Utility which provides a way to throw checked exceptions from the lambda expressions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLambdaExceptionUtils.BiConsumerWithExceptions<T,U,E extends Exception>Represents aBiConsumerinterface which can throw exceptions.static interfaceLambdaExceptionUtils.ConsumerWithExceptions<T,E extends Exception>Represents aConsumerinterface which can throw exceptions.static interfaceLambdaExceptionUtils.FunctionWithExceptions<T,R,E extends Exception>Represents aFunctioninterface which can throw exceptions.static interfaceLambdaExceptionUtils.RunnableWithExceptions<E extends Exception>Represents aRunnableinterface which can throw exceptions.static interfaceLambdaExceptionUtils.SupplierWithExceptions<T,E extends Exception>Represents aSupplierinterface which can throw exceptions.
-
Constructor Summary
Constructors Constructor Description LambdaExceptionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,U,E extends Exception>
BiConsumer<T,U>rethrowBiConsumer(LambdaExceptionUtils.BiConsumerWithExceptions<T,U,E> biConsumer)This method allows a BiConsumer which throws exceptions to be used in places which expects a BiConsumer.static <T,E extends Exception>
Consumer<T>rethrowConsumer(LambdaExceptionUtils.ConsumerWithExceptions<T,E> consumer)This method allows a Consumer which throws exceptions to be used in places which expects a Consumer.static <T,R,E extends Exception>
Function<T,R>rethrowFunction(LambdaExceptionUtils.FunctionWithExceptions<T,R,E> function)This method allows a Function which throws exceptions to be used in places which expects a Function.static <T,E extends Exception>
Supplier<T>rethrowSupplier(LambdaExceptionUtils.SupplierWithExceptions<T,E> function)This method allows a Supplier which throws exceptions to be used in places which expects a Supplier.
-
-
-
Method Detail
-
rethrowConsumer
public static <T,E extends Exception> Consumer<T> rethrowConsumer(LambdaExceptionUtils.ConsumerWithExceptions<T,E> consumer)
This method allows a Consumer which throws exceptions to be used in places which expects a Consumer.- Type Parameters:
T- the type of the input to the functionE- the type of Exception- Parameters:
consumer- instances of theConsumerWithExceptionsfunctional interface- Returns:
- an instance of the
Consumer
-
rethrowBiConsumer
public static <T,U,E extends Exception> BiConsumer<T,U> rethrowBiConsumer(LambdaExceptionUtils.BiConsumerWithExceptions<T,U,E> biConsumer)
This method allows a BiConsumer which throws exceptions to be used in places which expects a BiConsumer.- Type Parameters:
T- the type of the input to the functionU- the type of the input to the functionE- the type of Exception- Parameters:
biConsumer- instances of theBiConsumerWithExceptionsfunctional interface- Returns:
- an instance of the
BiConsumer
-
rethrowFunction
public static <T,R,E extends Exception> Function<T,R> rethrowFunction(LambdaExceptionUtils.FunctionWithExceptions<T,R,E> function)
This method allows a Function which throws exceptions to be used in places which expects a Function.- Type Parameters:
T- Any Object.R- Any ObjectE- Any Exception.- Parameters:
function- Function to apply for given arguments.- Returns:
- Any Object that result from the function passed.
-
rethrowSupplier
public static <T,E extends Exception> Supplier<T> rethrowSupplier(LambdaExceptionUtils.SupplierWithExceptions<T,E> function)
This method allows a Supplier which throws exceptions to be used in places which expects a Supplier.- Type Parameters:
T- Any Object.E- Any Exception.- Parameters:
function- Function to apply for given arguments.- Returns:
- Supplier of the results.
-
-