Class CommonsCollections4Helper
- java.lang.Object
-
- ch.powerunit.extensions.exceptions.CommonsCollections4Helper
-
public final class CommonsCollections4Helper extends Object
This class provides several helper methods for the functional interface of the commons-collections4.This class is only available if commons-collections4 is available
The mapping between the interface from commons-collections4 and this library is the following :
Mapping between interfaces commons-collections4 powerunit-extensions-exceptions Predicate PredicateWithException Factory SupplierWithException Transformer FunctionWithException Closure ConsumerWithException - Since:
- 2.2.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> org.apache.commons.collections4.Closure<T>asClosure(ConsumerWithException<T,?> consumer)Transforms aConsumerWithExceptionto the one from commons-collections.static <T> org.apache.commons.collections4.Factory<T>asFactory(SupplierWithException<T,?> supplier)Transforms aSupplierWithExceptionto the one from commons-collections.static <T> org.apache.commons.collections4.Predicate<T>asPredicate(PredicateWithException<T,?> predicate)Transforms aPredicateWithExceptionto the one from commons-collections.static <I,O> org.apache.commons.collections4.Transformer<I,O>asTransformer(FunctionWithException<I,O,?> function)Transforms aFunctionWithExceptionto the one from commons-collections.
-
-
-
Method Detail
-
asPredicate
public static <T> org.apache.commons.collections4.Predicate<T> asPredicate(PredicateWithException<T,?> predicate)
Transforms aPredicateWithExceptionto the one from commons-collections.- Type Parameters:
T- the type of the input argument for the predicate- Parameters:
predicate- thePredicateWithExceptionto be transformed to the one from commons-collections.- Returns:
- the
predicatefrom commons-collections. The ClassCastException and IllegalArgumentException are not wrapped and the other exception are wrapped in a FunctorException. - Throws:
NoClassDefFoundError- In case the commons-collections4 library is not available.NullPointerException- if predicate is null.- See Also:
Predicate
-
asFactory
public static <T> org.apache.commons.collections4.Factory<T> asFactory(SupplierWithException<T,?> supplier)
Transforms aSupplierWithExceptionto the one from commons-collections.- Type Parameters:
T- the type of the result of the supplier- Parameters:
supplier- theSupplierWithExceptionto be transformed to the one from commons-collections.- Returns:
- the
factoryfrom commons-collections. The exception are wrapped in a FunctorException. - Throws:
NoClassDefFoundError- In case the commons-collections4 library is not available.NullPointerException- if supplier is null.- See Also:
Factory
-
asTransformer
public static <I,O> org.apache.commons.collections4.Transformer<I,O> asTransformer(FunctionWithException<I,O,?> function)
Transforms aFunctionWithExceptionto the one from commons-collections.- Type Parameters:
I- the input argument type of the functionO- the result type of the function- Parameters:
function- theFunctionWithExceptionto be transformed to the one from commons-collections.- Returns:
- the
transformerfrom commons-collections. The ClassCastException and IllegalArgumentException are not wrapped and the other exception are wrapped in a FunctorException. - Throws:
NoClassDefFoundError- In case the commons-collections4 library is not available.NullPointerException- if function is null.- See Also:
Transformer
-
asClosure
public static <T> org.apache.commons.collections4.Closure<T> asClosure(ConsumerWithException<T,?> consumer)
Transforms aConsumerWithExceptionto the one from commons-collections.- Type Parameters:
T- the type of the input argument for the consumer- Parameters:
consumer- theConsumerWithExceptionto be transformed to the one from commons-collections.- Returns:
- the
closurefrom commons-collections. The ClassCastException and IllegalArgumentException are not wrapped and the other exception are wrapped in a FunctorException. - Throws:
NoClassDefFoundError- In case the commons-collections4 library is not available.NullPointerException- if consumer is null.- See Also:
Closure
-
-